UNet#
- class deepinv.models.UNet(in_channels=1, out_channels=1, residual=True, circular_padding=False, cat=True, bias=True, batch_norm=True, scales=4, device=None, dim=2)[source]#
Bases:
DenoiserU-Net convolutional denoiser.
This network is a fully convolutional denoiser based on the U-Net architecture. The number of downsample steps can be controlled with the
scalesparameter. The number of trainable parameters increases with the number of scales.Warning
When using the bias-free batch norm
BFBatchNorm2dviabatch_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 output and output.
circular_padding (bool) – circular padding for the convolutional layers.
cat (bool) – use skip-connections between intermediate levels.
bias (bool) – use learnable biases.
batch_norm (bool, str) – if False, no batchnorm applied, if
True, usetorch.nn.BatchNorm2d, ifbatch_norm="biasfree", useBFBatchNorm2dfrom Mohan et al.[1].scales (int) – Number of downsampling steps used in the U-Net. The options are 2,3,4 and 5. The number of trainable parameters increases with the scale.
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