Menu

Deep learning for NeuroImaging in Python.

Note

This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the gallery for the big picture.

class nidl.volume.backbones.resnet3d.ResNetTruncated(*args, depth: int = 0, **kwargs)[source]

Bases: ResNet

3D truncated ResNet-18 architecture adapted from He et al. 2015. See https://doi.org/10.48550/arXiv.1512.03385 for details.

Parameters:

block : BasicBlock or Bottleneck

which convolution block to apply (4 in total). This should be a class type and not its instance.

layers : (int, int, int, int)

now many layers in each conv block (4 in total).

depth : int, default=0

the model depth in [0, 4].

in_channels : int, default=1

now many input channels has the input.

zero_init_residual : bool, default=False

zero-initialize the last BN in each residual branch, so that the residual branch starts with zeros, and each residual block behaves like an identity. This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677.

groups : int, default=1

how many groups to divide the input channels into in grouped 3x3 convolution of Bottleneck block (e.g. in Resnet50).

width_per_group : int, default=64

number of channels per group in the grouped 3x3 convolution of Bottleneck block (e.g. in ResNet50). Effective width = groups * width_per_group.

replace_stride_with_dilation : None or [bool, bool, bool], default=None

by default, ResNet reduces spatial resolution of input feature maps using stride 2 conv in layers 2, 3, 4. This replaces some layers with stride=2 by dilation (atrous) conv, preserving spatial resolution. It is useful for dense tasks such as segmentation.

norm_layer : None or Type[nn.Module], default=None

which normalization to apply after each layer. If None, nn.BatchNorm3d is applied.

initial_kernel_size : int, default=7

kernel size in the first conv layer.

n_embedding : int, default=512

the size of the embedding space.

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Follow us

© 2025, nidl developers