res_unet_2d(pretrained: bool = False, overrides: object = {})ResUNet — U-Net with residual DoubleConv blocks, 2-D.
Builds a 2-D U-Net with the standard channel / depth schedule but every DoubleConv block wraps an identity shortcut around its two 3x3 convs. This residual variant trains more reliably at greater depth and is a common drop-in upgrade for medical-imaging U-Nets.
Model Size
Parameters
pretrainedbool= Falseres_unet_2d, so True raises
NotImplementedError rather than return randomly initialised weights.**overridesobject= {}UNetConfig (num_classes,
in_channels, base_channels, depth, ...).Returns
UNetForSemanticSegmentationSegmentation model with the 2-D ResUNet configuration applied
(or with overrides merged on top of it).
Notes
This is a residual U-Net, not Deep ResUNet. The DoubleConv update with residual shortcut is
the He et al. residual formulation applied at every encoder / decoder stage rather than only inside a backbone.
Zhang, Liu, Wang, "Road Extraction by Deep Residual U-Net" (IEEE Geosci. Remote Sens. Lett. 2018, arXiv:1711.10684) describes a different network and is deliberately not cited as this model's source: it uses full pre-activation units (BN → ReLU → Conv twice, with no activation after the addition), replaces every pooling layer with a stride-2 convolution, and has three encoding levels plus a bridge — 15 convolutions and 7.8 M parameters against this model's post-activation blocks, max-pooling, four levels and 32.4 M parameters. A caller wanting the paper's architecture wants a separate implementation, not this factory.
Examples
>>> import lucid
>>> from lucid.models.vision.unet import res_unet_2d
>>> model = res_unet_2d()
>>> x = lucid.randn(1, 1, 256, 256)
>>> out = model(x)
>>> out.logits.shape
(1, 2, 256, 256)