torch_geometric.nn.aggr.DeepSetsAggregation
- class DeepSetsAggregation(local_nn: Optional[Module] = None, global_nn: Optional[Module] = None)[source]
Bases:
AggregationPerforms Deep Sets aggregation in which the elements to aggregate are first transformed by a Multi-Layer Perceptron (MLP) \(\phi_{\mathbf{\Theta}}\), summed, and then transformed by another MLP \(\rho_{\mathbf{\Theta}}\), as suggested in the “Graph Neural Networks with Adaptive Readouts” paper.
- Parameters
local_nn (torch.nn.Module, optional) – The neural network \(\phi_{\mathbf{\Theta}}\), e.g., defined by
torch.nn.Sequentialortorch_geometric.nn.models.MLP. (default:None)global_nn (torch.nn.Module, optional) – The neural network \(\rho_{\mathbf{\Theta}}\), e.g., defined by
torch.nn.Sequentialortorch_geometric.nn.models.MLP. (default:None)
- forward(x: Tensor, index: Optional[Tensor] = None, ptr: Optional[Tensor] = None, dim_size: Optional[int] = None, dim: int = -2) 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)