Skip to content

SetAttentionBlock

SetAttentionBlock(
    channels: int, heads: int = 1, layer_norm: bool = True, dropout: float = 0.0
)

Bases: Module

The Set Attention Block (SAB) from the "Set Transformer" paper: \(\mathrm{SAB}(\mathbf{X}) = \mathrm{MAB}(\mathbf{x}, \mathbf{y})\).

Parameters:

Name Type Description Default
channels int

Size of each input sample.

required
heads int

Number of attention heads. Default: 1

1
layer_norm bool

Whether to apply layer normalization. Default: True

True
dropout float

Dropout probability of the attention weights. Default: 0.0

0.0
Source code in mlx_graphs/nn/aggr/utils.py
def __init__(
    self,
    channels: int,
    heads: int = 1,
    layer_norm: bool = True,
    dropout: float = 0.0,
):
    super().__init__()
    self.mab = MultiheadAttentionBlock(channels, heads, layer_norm, dropout)

from mlx_graphs.nn.aggr import SetAttentionBlock · mlx_graphs/nn/aggr/utils.py