Skip to content

InducedSetAttentionBlock

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

Bases: Module

The Induced Set Attention Block (ISAB) from the "Set Transformer" paper: \(\mathrm{ISAB}(\mathbf{X}) = \mathrm{MAB}(\mathbf{x}, \mathbf{h})\) with \(\mathbf{h} = \mathrm{MAB}(\mathbf{I}, \mathbf{x})\) for learnable induced points \(\mathbf{I}\).

Parameters:

Name Type Description Default
channels int

Size of each input sample.

required
num_induced_points int

Number of induced points.

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,
    num_induced_points: int,
    heads: int = 1,
    layer_norm: bool = True,
    dropout: float = 0.0,
):
    super().__init__()
    self.ind = _xavier((1, num_induced_points, channels))
    self.mab1 = MultiheadAttentionBlock(channels, heads, layer_norm, dropout)
    self.mab2 = MultiheadAttentionBlock(channels, heads, layer_norm, dropout)

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