scimba_torch.neural_nets.embeddings.periodic_embedding

Periodic and flipped embeddings.

Classes

FlippedEmbedding(in_size, out_size)

Creates a one-layer network to model a flipped embedding of the input data.

PeriodicEmbedding(in_size, out_size, periods)

Creates a one-layer network to model a periodic embedding of the input data.

class PeriodicEmbedding(in_size, out_size, periods)[source]

Bases: Module

Creates a one-layer network to model a periodic embedding of the input data.

The learnable parameters are the weights, phases and biases of the periodic functions.

Parameters:
  • in_size (int) – dimension of inputs

  • out_size (int) – dimension of outputs

  • periods (Tensor) – periods of the periodic functions

weight: torch.nn.Parameter

the weights of the layer

phase: torch.nn.Parameter

the phase of the layer

bias: torch.nn.Parameter

the bias of the layer

forward(x)[source]

Forward pass of the periodic embedding layer.

Parameters:

x (Tensor) – input tensor

Return type:

Tensor

Returns:

output tensor

class FlippedEmbedding(in_size, out_size)[source]

Bases: Module

Creates a one-layer network to model a flipped embedding of the input data.

It is only available for 2D inputs on the unit square.

Parameters:
  • in_size (int) – dimension of inputs

  • out_size (int) – dimension of outputs

forward(x)[source]

Forward pass of the flipped embedding layer.

Parameters:

x (Tensor) – input tensor

Return type:

Tensor

Returns:

output tensor