noether.modeling.modules.layers.linear_projection¶
Classes¶
Configuration for a LinearProjection layer. |
|
LinearProjection is a linear projection layer that can be used for 1D, 2D, and 3D data. |
Module Contents¶
- class noether.modeling.modules.layers.linear_projection.LinearProjectionConfig(/, **data)¶
Bases:
pydantic.BaseModelConfiguration for a LinearProjection layer.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- ndim: None | int = None¶
Number of dimensions of the input domain. Either None (Linear projection), 1D (sequence), 2D, or 3D. Defaults to None.
- optional: bool = None¶
If true and input_dim==output_dim (i.e., there is no up/down projection), then the identity mapping is used. Defaults to False.
- init_weights: noether.core.types.InitWeightsMode = None¶
Initialization method of the weights of the MLP. Options are ‘torch’ (i.e., similar to the module) or ‘truncnormal002’, or ‘zero’. Defaults to ‘torch’.
- validate_ndim()¶
Validate the ndim field to ensure it is either None, 1, 2, or 3.
- Return type:
Self
- class noether.modeling.modules.layers.linear_projection.LinearProjection(config)¶
Bases:
torch.nn.ModuleLinearProjection is a linear projection layer that can be used for 1D, 2D, and 3D data.
- Parameters:
config (LinearProjectionConfig) – The configuration of the LinearProjection. See
LinearProjectionConfigfor available options.- Raises:
NotImplementedError – raises not implemented error if the number of dimensions of the input domain is bigger than 4.
- project: torch.nn.Linear | torch.nn.Conv1d | torch.nn.Conv2d | torch.nn.Conv3d | torch.nn.Identity¶
- init_weights¶
- reset_parameters()¶
- Reset the parameters of the MLP with a specific initialization. Options are “torch” (i.e., default) or
“truncnormal002”.
- Raises:
NotImplementedError – raised if the specified initialization is not implemented.
- Return type:
None
- forward(x)¶
Forward function of the LinearProjection.
- Parameters:
x (torch.Tensor) – Input tensor to the LinearProjection.
- Returns:
Output tensor from the LinearProjection.
- Return type: