SoftmaxAggregation
¶
SoftmaxAggregation(
t: float = 1.0,
learn: bool = False,
semi_grad: bool = False,
channels: int = 1,
)
Bases: Aggregation
Softmax aggregation with an (optionally learnable) inverse temperature, from "DeeperGCN: All You Need to Train Deeper GCNs" paper.
where \(t\) controls the softness of the softmax: \(t \to 0\) gives the mean and \(t \to \infty\) the maximum.
Note
This is an aggregation (one output per set). The "softmax"
string of scatter() and of
MessagePassing instead normalizes the values
within each set (one output per element), e.g. for attention scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
float
|
Initial inverse temperature. Default: |
1.0
|
learn
|
bool
|
If |
False
|
semi_grad
|
bool
|
If |
False
|
channels
|
int
|
Number of learnable temperatures. With more than 1, one
temperature is learned per feature channel ( |
1
|
Example:
import mlx.core as mx
from mlx_graphs.nn.aggr import SoftmaxAggregation
aggr = SoftmaxAggregation(t=1.0, learn=True)
x = mx.random.normal((6, 16))
index = mx.array([0, 0, 1, 1, 1, 2])
>>> aggr(x, index).shape
(3, 16)
Methods:
| Name | Description |
|---|---|
reset_parameters |
Resets the temperature to its initial value. |
Source code in mlx_graphs/nn/aggr/basic.py
from mlx_graphs.nn.aggr import SoftmaxAggregation · mlx_graphs/nn/aggr/basic.py