torch_geometric.nn.aggr.LSTMAggregation
- class LSTMAggregation(in_channels: int, out_channels: int, **kwargs)[source]
Bases:
Aggregation执行LSTM风格的聚合,其中要聚合的元素被解释为一个序列,如“Inductive Representation Learning on Large Graphs”论文中所述。
注意
LSTMAggregation需要排序后的索引index作为输入。 具体来说,如果你将此聚合用作MessagePassing的一部分,请确保edge_index按目标节点排序,可以通过手动 使用sort_edge_index()排序边索引 或调用torch_geometric.data.Data.sort()来实现。警告
LSTMAggregation不是一个排列不变的运算符。- Parameters:
in_channels (int) – Size of each input sample.
out_channels (int) – 每个输出样本的大小。
**kwargs (可选) –
torch.nn.LSTM的额外参数。
- forward(x: Tensor, index: Optional[Tensor] = None, ptr: Optional[Tensor] = None, dim_size: Optional[int] = None, dim: int = -2, max_num_elements: Optional[int] = None) Tensor[source]
前向传播。
- Parameters:
x (torch.Tensor) – The source tensor.
index (torch.Tensor, optional) – The indices of elements for applying the aggregation. One of
indexorptrmust be defined. (default:None)ptr (torch.Tensor, optional) – If given, computes the aggregation based on sorted inputs in CSR representation. One of
indexorptrmust be defined. (default:None)dim_size (int, optional) – The size of the output tensor at dimension
dimafter aggregation. (default:None)dim (int, optional) – The dimension in which to aggregate. (default:
-2)max_num_elements (
Optional[int], default:None) – (int, optional): The maximum number of elements within a single aggregation group. (default:None)
- Return type: