direct.nn.resnet package#
Submodules#
direct.nn.resnet.config module#
- class direct.nn.resnet.config.ResNetConfig(model_name: str = '???', engine_name: str | None = None, in_channels: int = 2, out_channels: int | None = None, hidden_channels: int = 32, num_blocks: int = 15, batchnorm: bool = True, scale: float | None = 0.1, image_init: str = 'sense')[source][source]#
Bases:
ModelConfig
-
batchnorm:
bool
= True#
-
image_init:
str
= 'sense'#
-
in_channels:
int
= 2#
-
num_blocks:
int
= 15#
-
out_channels:
Optional
[int
] = None#
-
scale:
Optional
[float
] = 0.1#
-
batchnorm:
direct.nn.resnet.resnet module#
- class direct.nn.resnet.resnet.ResNet(hidden_channels, in_channels=2, out_channels=None, num_blocks=15, batchnorm=True, scale=0.1)[source][source]#
Bases:
Module
Simple residual network.
Consisted of a sequence of
ResNetBlocks
followed optionally by batch normalization blocks, followed by an output convolution layer.- forward(input_image)[source][source]#
Computes forward pass of
ResNet
.- Parameters:
- input_image: torch.Tensor
Masked k-space of shape (N, in_channels, height, width).
- Returns:
- output: torch.Tensor
Output image of shape (N, height, width, complex=2).
- Return type:
Tensor
-
training:
bool
#
- class direct.nn.resnet.resnet.ResNetBlock(in_channels, hidden_channels, scale=0.1)[source][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.
- forward(x)[source][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.
-
training:
bool
#