mr2.nn.nets.AttentionGatedUNet

class mr2.nn.nets.AttentionGatedUNet[source]

Bases: UNetBase

UNet with attention gates.

Basic UNet with attention gating of the skip signals by the lower resolution features [OKT18].

References

[OKT18]

Oktay, Ozan, et al. “Attention U-net: Learning where to look for the pancreas.” MIDL (2018). https://arxiv.org/abs/1804.03999

__init__(n_dim: int, n_channels_in: int, n_channels_out: int, n_features: Sequence[int], cond_dim: int = 0)[source]

Initialize the AttentionGatedUNet.

Parameters:
  • n_dim (int) – The number of spatial dimensions of the input tensor.

  • n_channels_in (int) – The number of channels in the input tensor.

  • n_channels_out (int) – The number of channels in the output tensor.

  • n_features (Sequence[int]) – Number of features at each resolution level. The length determines the number of resolution levels.

  • cond_dim (int, default: 0) – Number of channels in the conditioning tensor. If 0, no conditioning is applied.

encoder

The encoder.

decoder

The decoder.

skip_blocks

Modifications of the skip connections.

__call__(x: Tensor, *, cond: Tensor | None = None) → Tensor[source]

Apply to Network.

Parameters:
  • x (Tensor) – The input tensor.

  • cond (Tensor | None, default: None) – The conditioning tensor.

Returns:

The output tensor.

forward(x: Tensor, *, cond: Tensor | None = None) → Tensor[source]

Apply to Network.