attention_unet(pretrained: bool = False, overrides: object = {})Attention U-Net (Oktay et al., MIDL 2018).
Builds an AttentionUNetForSemanticSegmentation with the
standard configuration: 4-level encoder / decoder, base_channels = 64 (channel schedule 64 -> 128 -> 256 -> 512 -> 1024),
in_channels = 1 (medical imaging default), and num_classes = 2.
Soft attention gates on every skip connection suppress irrelevant
encoder activations.
Model Size
Parameters
pretrainedbool= FalseReserved for future pretrained-weight loading. Currently ignored.
**overridesobject= {}Keyword overrides forwarded into
AttentionUNetConfig
(num_classes, in_channels for RGB inputs,
base_channels, depth, bilinear).Returns
AttentionUNetForSemanticSegmentationSegmentation model with the standard Attention U-Net
configuration applied (or with overrides merged on top of it).
Notes
See Oktay et al., "Attention U-Net: Learning Where to Look for the Pancreas", MIDL 2018 (arXiv:1804.03999). The defining attention-gate update is
where is the encoder feature at level and is the up-sampled decoder feature serving as the gating signal.
Examples
>>> import lucid
>>> from lucid.models.vision.attention_unet import attention_unet
>>> model = attention_unet(num_classes=4, in_channels=3)
>>> x = lucid.randn(1, 3, 256, 256)
>>> out = model(x)
>>> out.logits.shape
(1, 4, 256, 256)