phlower.nn.GraphLaplacian

class phlower.nn.GraphLaplacian(support_name, factor=1.0, nodes=None)[source]

Bases: IGenericPhlowerCoreModule[IPhlowerLayerParameters, PhlowerTensor], Module

GraphLaplacian applies the graph Laplacian of the support A: (L h)_i = factor * sum_j A_ij (h_j - h_i), that is L = factor * (A - D) with the degree matrix D_ii = sum_j A_ij.

The output is zero on a constant field, so L works as a high-pass filter: it removes the smooth part of h and keeps the variations between neighboring nodes.

input: ([t,] n_nodes, …, f) output: ([t,] n_nodes, …, f) t is optional.

Parameters:
  • support_name (str) – Name of the support tensor A, of shape (n_nodes, n_nodes).

  • factor (float) – Factor to multiply the Laplacian.

  • nodes (list[int] | None)

Examples

>>> graph_laplacian = GraphLaplacian(support_name="support")
>>> graph_laplacian(data, field_data=field_data)

Methods

forward(data, *, field_data, **kwards)

forward function which overloads torch.nn.Module

from_setting(setting)

Create GraphLaplacian from setting object

get_nn_name()

Return neural network name

Attributes

T_destination

call_super_init

dump_patches

training

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

classmethod from_setting(setting)[source]

Create GraphLaplacian from setting object

Parameters:

setting (GraphLaplacianSetting) – setting object

Returns:

GraphLaplacian object

Return type:

GraphLaplacian

classmethod get_nn_name()[source]

Return neural network name

Returns:

name

Return type:

str