UNet#
- class deepinv.models.UNet(in_channels=1, out_channels=1, residual=True, circular_padding=False, cat=True, bias=True, batch_norm=True, scales=None, channels_per_scale=None, device='cpu', dim=2)[source]#
Bases:
DenoiserU-Net convolutional denoiser.
This network is a fully convolutional denoiser based on the U-Net architecture. The number of stages in the network is controlled by
scales. The width of each stage is controlled bychannels_per_scale, which gives the number of feature maps at each stage, from shallow to deeper stages. The number of trainable parameters increases with bothscalesand the values inchannels_per_scale.If
scalesis not given, it is inferred fromchannels_per_scale. If both are omitted, defaults tochannels_per_scale=[64, 128, 256, 512]. If onlyscalesis specified,channels_per_scale=[64 * (2**k) for k in range(scales)]. When both are specified,scalesmust match the length ofchannels_per_scale.Warning
When using the bias-free batch norm via
batch_norm="biasfree", NaNs may be encountered during training, causing the whole training procedure to fail.- Parameters:
in_channels (int) β input image channels
out_channels (int) β output image channels
residual (bool) β use a skip-connection between input and output.
circular_padding (bool) β circular padding for the convolutional layers.
cat (bool) β use skip-connections between intermediate levels.
bias (bool) β use learnable biases in conv and norm layers.
batch_norm (bool, str) β if False, disable normalization entirely, if
True, use batch normalization, ifbatch_norm="biasfree", use the bias-free batch norm from Mohan et al.[1].scales (int) β Number of stages.
channels_per_scale (Sequence[int]) β Number of feature maps at each stage (from shallow to deep).
device (torch.device, str) β Device to put the model on.
dim (str, int) β Whether to build 2D or 3D network (if str, can be β2β, β2dβ, β3Dβ, etc.)
- References:
- forward(x, sigma=None, **kwargs)[source]#
Run the denoiser on noisy image. The noise level is not used in this denoiser.
- Parameters:
x (torch.Tensor) β noisy image.
sigma (float) β noise level (not used).
Examples using UNet:#
Imaging inverse problems with adversarial networks
Self-supervised learning from incomplete measurements of multiple operators.
Self-supervised denoising with the Neighbor2Neighbor loss.
Self-supervised denoising with the Generalized R2R loss.
Self-supervised learning with measurement splitting