phlower.nn.MeanConstrainedSigmoid¶
- class phlower.nn.MeanConstrainedSigmoid(output_feature_dim, reference_variable_name, weight_field_name=None, slope=2.0, learnable_slope=False, convergence_threshold=1e-05, max_iteration=100, epsilon=1e-06, **kwards)[source]¶
Bases:
IGenericPhlowerCoreModule[IPhlowerLayerParameters,PhlowerTensor],ModuleMeanConstrainedSigmoid projects the input feature to (0, 1)-valued features with its mean equaling to the given mean. It applies sigmoid(a * h + b), with b determined by solving the equation mean sigmoid(a * h + b) = target_mean.
- Parameters:
output_feature_dim (int) – Output feature dimension.
reference_variable_name (str) – Variable name to compute the target mean.
weight_field_name (str | None = None) – Name of weight (e.g., volume) data in field_data.
slope (float = 2.0) – Slope of the linear transformation before sigmoid. If learnable_slope is True, it is used as an initial value.
learnable_slope (bool = False) – If True, lean slope.
convergence_threshold (float = 1e-5) – Threshould for the Newton solver to obtain the target mean.
max_iteration (int = 100) – Max iteration for the Newton solver.
epsilon (float = 1.0e-6) – Small value to suppress numerical instability.
Examples
>>> mix = MeanConstrainedSigmoid(reference_variable_name="a") >>> mix(data)
Methods
forward(data, *[, field_data])forward function which overloads torch.nn.Module
from_setting(setting)Create MeanConstrainedSigmoid from setting object
Return name of MeanConstrainedSigmoid
Attributes
T_destinationcall_super_initdump_patchestraining- 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