phlower.nn.NodalExpand

class phlower.nn.NodalExpand(reference_key, nodes=None, unbatch_key=None)[source]

Bases: IGenericPhlowerCoreModule[IPhlowerLayerParameters, PhlowerTensor], Module

Expand an input to the node count of the named reference input.

Parameters:
  • reference_key (str) – The key of the reference input to match the node count.

  • nodes (list[int] | None, optional) – The node configuration for the expanded output, by default None.

  • unbatch_key (str | None, optional) – The key used for unbatching the input tensors, by default None.

Notes

The source input must have exactly one node. Voxel tensors are not supported.

Examples

>>> source = phlower_tensor(torch.randn(1, 3))
>>> reference = phlower_tensor(torch.randn(5, 3))
>>> expanded = _expand(source, reference)
>>> expanded.shape
torch.Size([5, 3])

Methods

forward(data, *[, field_data])

Define the computation performed at every call.

from_setting(setting)

get_nn_name()

Attributes

T_destination

call_super_init

dump_patches

training

forward(data, *, field_data=None, **kwargs)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:
  • data (IPhlowerTensorCollections)

  • field_data (ISimulationField | None)

Return type:

PhlowerTensor