phlower.nn.NaNToNum¶
- class phlower.nn.NaNToNum(nodes=None, nan=0.0, posinf=None, neginf=None)[source]¶
Bases:
Module,IGenericPhlowerCoreModule[IPhlowerLayerParameters,PhlowerTensor]NaNToNum is a neural network module that replaces NaN and infinite values in the input tensor with specified numerical values.
- Parameters:
nan (float) – The value to replace NaN values with. Default is 0.0.
posinf (float | None) – The value to replace positive infinity values with. Default is None, which means positive infinity values are not replaced.
neginf (float | None) – The value to replace negative infinity values with. Default is None, which means negative infinity values are not replaced.
nodes (list[int] | None)
Examples
>>> nan_to_num = NaNToNum(nan=0.0, posinf=1e6, neginf=-1e6) >>> nan_to_num(data)
Methods
forward(data, *[, field_data])forward function which overloads torch.nn.Module
from_setting(setting)Generate MLP from setting object
Return neural network name
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