mr2.nn.attention.ConvolutionalAttention
- class mr2.nn.attention.ConvolutionalAttention[source]
Bases:
ModuleTemporal or patch attention with spatial convolutional projections.
Implements the attention used by the released SNRAware imaging transformers [XUE25]. Spatial relative-position bias is added after softmax, following the official implementation [SNRAWARE] rather than the usual logit bias.
References
[XUE25]Xue et al. SNRAware: Improved Deep Learning MRI Denoising with SNR Unit Training and G-factor Map Augmentation. https://arxiv.org/abs/2503.18162
[SNRAWARE]Microsoft SNRAware. https://github.com/microsoft/SNRAware
- __init__(n_channels: int, n_heads: int, image_size: int, mode: Literal['temporal', 'local', 'global']) None[source]
Initialize convolutional attention.
- Parameters:
n_channels (
int) – Number of input and output channels.n_heads (
int) – Number of heads. Must divide the channel count.image_size (
int) – Height and width of the input. Must be divisible by eight.mode (
Literal['temporal','local','global']) – Attend across frames, four patches within each local window, or all spatial patches within each frame.