emmi.modules.layers.linear_projection

Classes

LinearProjection

LinearProjection is a linear projection layer that can be used for 1D, 2D, and 3D data.

Module Contents

class emmi.modules.layers.linear_projection.LinearProjection(config)

Bases: torch.nn.Module

LinearProjection is a linear projection layer that can be used for 1D, 2D, and 3D data.

Initialize the LinearProjection.

Parameters:
  • input_dim – Input dimension of the linear projection.

  • output_dim – Output dimension of the linear projection.

  • ndim – Number of dimensions of the input domain. Either None (Linear projection), 1D (sequence), 2D, or 3D. Defaults to None.

  • bias – If true, use bias term in the linear projection. Defaults to True.

  • optional – 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 – Initialization method of the weights of the MLP. Options are “torch” (i.e., similar to the module) or “truncnormal002”. Defaults to “truncnormal002”. Defaults to “torch”.

  • config (emmi.schemas.modules.layers.LinearProjectionConfig)

Raises:

NotImplementedError – raises not implemented error if the number of dimensions of the input domain is bigger than 4.

project: torch.nn.Module
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:

torch.Tensor