phlower.nn.Contraction

class phlower.nn.Contraction(activation, nodes=None)[source]

Bases: IPhlowerCoreModule, Module

Contraction is a neural network module that performs a contraction operation on the input tensor.

This module is designed to reduce the dimensionality of the input tensor by summing over specified dimensions.

Parameters:
  • nodes (list[int] | None (optional)) – List of feature dimension sizes (The last value of tensor shape). Defaults to None.

  • activation (str (optional)) – Name of the activation function to apply to the output. Defaults to “identity” (no activation).

Examples

>>> contraction = Contraction(activation="relu")
>>> contraction(data)

Methods

forward(data, *[, field_data])

forward function which overloads torch.nn.Module

from_setting(setting)

Create Contraction from setting object

get_nn_name()

Return name of Contraction

Attributes

T_destination

call_super_init

dump_patches

training

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

forward function which overloads torch.nn.Module

Parameters:
  • data (IPhlowerTensorCollections) – IPhlowerTensorCollections data which receives from predecessors

  • field_data (ISimulationField | None) – ISimulationField | None Constant information through training or prediction

Returns:

Tensor object

Return type:

PhlowerTensor

classmethod from_setting(setting)[source]

Create Contraction from setting object

Parameters:

setting (ContractionSetting) – setting object

Returns:

Contraction

Return type:

Self

classmethod get_nn_name()[source]

Return name of Contraction

Returns:

name

Return type:

str