mr2.nn.FourierFeatures

class mr2.nn.FourierFeatures[source]

Bases: Module

Fourier feature encoding layer.

Projects input features into a higher dimensional space using random Fourier features. Used in INRs and to embed the time or other continuous variables.

__init__(n_features_in: int, n_features_out: int, std: float = 1.0)[source]

Initialize Fourier feature encoding layer.

Parameters:
  • n_features_in (int) – Number of input features

  • n_features_out (int) – Number of output features (must be even)

  • std (float, default: 1.0) – Standard deviation for random initialization

__call__(x: Tensor) → Tensor[source]

Apply Fourier feature encoding.

Parameters:

x (Tensor) – Input tensor of shape (…, in_features)

Returns:

Encoded features of shape (…, out_features)

forward(x: Tensor) → Tensor[source]

Apply Fourier feature encoding.