phlower.nn.EdgeDifference¶
- class phlower.nn.EdgeDifference(support_name, with_norm=False, nodes=None)[source]¶
Bases:
IGenericPhlowerCoreModule[IPhlowerLayerParameters,PhlowerTensor],ModuleEdgeDifference computes the difference between the nodal features of the two endpoints of each edge:
e_k = h_j - h_ifor the k-th edge (i, j). Self-loop edges are ignored.input: ([t,] n_nodes, …, f) output: ([t,] n_edges, …, f)
tis optional.When
with_normis True, the L2 norm of the difference is concatenated to the output, which then has shape ([t,] n_edges, f + 1).Applied to node positions, this yields the relative position and distance edge features used in MeshGraphNets.
- Parameters:
support_name (str) – Name of the support tensor defining the edges.
with_norm (bool) – Whether to concatenate the L2 norm of the difference to the output. Only available for rank-0 tensors. Defaults to False.
nodes (list[int] | None)
Examples
>>> edge_difference = EdgeDifference( ... support_name="support", with_norm=True ... ) >>> edge_difference(data, field_data=field_data)
Methods
forward(data, *, field_data, **kwards)forward function which overloads torch.nn.Module
from_setting(setting)Create EdgeDifference from setting object
Return neural network name
Attributes
T_destinationcall_super_initdump_patchestraining- forward(data, *, field_data, **kwards)[source]¶
forward function which overloads torch.nn.Module
- Parameters:
data (IPhlowerTensorCollections) – IPhlowerTensorCollections data which receives from predecessors
field_data (ISimulationField) – ISimulationField | None Constant information through training or prediction
- Returns:
Tensor object
- Return type:
PhlowerTensor