direct.nn.resnet package#

Submodules#

direct.nn.resnet.config module#

class direct.nn.resnet.config.ResNetConfig(model_name='???', engine_name=None, in_channels=2, out_channels=None, hidden_channels=32, num_blocks=15, batchnorm=True, scale=0.1, image_init='sense')[source]#

Bases: ModelConfig

in_channels = 2#
out_channels = None#
hidden_channels = 32#
num_blocks = 15#
batchnorm = True#
scale = 0.1#
image_init = 'sense'#
__init__(model_name='???', engine_name=None, in_channels=2, out_channels=None, hidden_channels=32, num_blocks=15, batchnorm=True, scale=0.1, image_init='sense')#

direct.nn.resnet.resnet module#

class direct.nn.resnet.resnet.ResNetBlock(in_channels, hidden_channels, scale=0.1)[source]#

Bases: Module

Main block of ResNet.

Consisted of a convolutional layer followed by a relu activation, a second convolution, and finally a scaled skip connection with the input.

__init__(in_channels, hidden_channels, scale=0.1)[source]#

Inits ResNetBlock.

Parameters:
  • in_channels (int) – Input channels.

  • hidden_channels (int) – Hidden channels (output channels of first conv).

  • scale (Optional[float]) – Float that will scale the output of the convolutions before adding the input. Default: 0.1.

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses. :rtype: Tensor

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.

class direct.nn.resnet.resnet.ResNet(hidden_channels, in_channels=2, out_channels=None, num_blocks=15, batchnorm=True, scale=0.1)[source]#

Bases: Module

Simple residual network.

Consisted of a sequence of :obj:`ResNetBlock`s followed optionally by batch normalization blocks, followed by an output convolution layer.

__init__(hidden_channels, in_channels=2, out_channels=None, num_blocks=15, batchnorm=True, scale=0.1)[source]#

Inits ResNet.

Parameters:
  • hidden_channels (int) – Hidden dimension.

  • in_channels (int) – Input dimension. Default: 2 (for MRI).

  • out_channels (Optional[int]) – Output dimension. If None, will be the same as in_channels. Default: None.

  • num_blocks (int) – Number of ResNetBlock`s. Default: ``15`.

  • batchnorm (bool) – If True, batch normalization will be performed after each ResNetBlock. Default: True.

  • scale (Optional[float]) – Scale parameter for ResNetBlock. Default: 0.1.

forward(input_image)[source]#

Computes forward pass of ResNet.

Parameters:

input_image (Tensor) – Masked k-space of shape (N, in_channels, height, width).

Return type:

Tensor

Returns:

Output image of shape (N, height, width, complex=2).

Module contents#