LSTMAggregation
¶
Bases: _RecurrentAggregation
Aggregation with an LSTM, from the "Inductive Representation Learning on Large Graphs" paper, as PyG's
LSTMAggregation.
The elements of each set are padded with zeros to the size of the largest set and fed to an LSTM in input order. The output is the last hidden state.
Warning
The aggregation is not permutation-invariant: it depends on the order of the elements in each set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_features_dim
|
int
|
Size of each input sample. |
required |
out_features_dim
|
int
|
Size of each output sample (hidden size of the LSTM). |
required |
bias
|
Whether the LSTM has biases. Default: |
True
|
Example:
import mlx.core as mx
from mlx_graphs.nn.aggr import LSTMAggregation
aggr = LSTMAggregation(16, 32)
x = mx.random.normal((6, 16))
index = mx.array([0, 0, 1, 1, 1, 2])
>>> aggr(x, index).shape
(3, 32)
Source code in mlx_graphs/nn/aggr/rnn.py
from mlx_graphs.nn.aggr import LSTMAggregation · mlx_graphs/nn/aggr/rnn.py