PoolingByMultiheadAttention
¶
PoolingByMultiheadAttention(
channels: int,
num_seed_points: int = 1,
heads: int = 1,
layer_norm: bool = True,
dropout: float = 0.0,
)
Bases: Module
The Pooling by Multihead Attention (PMA) layer from the "Set Transformer" paper: \(\mathrm{PMA}(\mathbf{X}) = \mathrm{MAB}(\mathbf{S}, \mathrm{ReLU}(\mathbf{X}\mathbf{W}))\) for learnable seed points \(\mathbf{S}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channels
|
int
|
Size of each input sample. |
required |
num_seed_points
|
int
|
Number of seed points. Default: |
1
|
heads
|
int
|
Number of attention heads. Default: |
1
|
layer_norm
|
bool
|
Whether to apply layer normalization. Default: |
True
|
dropout
|
float
|
Dropout probability of the attention weights. Default: |
0.0
|
Source code in mlx_graphs/nn/aggr/utils.py
from mlx_graphs.nn.aggr import PoolingByMultiheadAttention · mlx_graphs/nn/aggr/utils.py