scimba_torch.neural_nets.structure_preserving_nets.symplectic_nets

Symplectic neural networks composed of invertible layers.

Classes

GSymplecticNet(size, conditional_size, ...)

An invertible neural network composed of multiple invertible layers.

LASymplecticNet(size, conditional_size, ...)

An invertible neural network composed of multiple invertible layers.

PSymplecticNet(size, conditional_size, deg, ...)

An invertible neural network composed of multiple invertible layers.

PeriodicGSymplecticNet(size, ...)

An invertible neural network composed of multiple invertible layers.

class GSymplecticNet(size, conditional_size, width, nb_layers, **kwargs)[source]

Bases: InvertibleNet

An invertible neural network composed of multiple invertible layers.

Parameters:
  • size (int) – dimension of the input data

  • conditional_size (int) – dimension of the conditional input data

  • width (int) – width of the hidden layers in each layer

  • nb_layers (int) – number of invertible layers to compose

  • **kwargs – other arguments for the invertible layers

log_abs_det_jacobian(y, mu)[source]

Computes the log absolute determinant of the Jacobian.

Parameters:
  • y (Tensor) – Input tensor of shape (batch_size, size).

  • mu (Tensor) – Conditional input of shape (batch_size, conditional_size).

Return type:

Tensor

Returns:

Log determinant of shape (batch_size,).

abs_det_jacobian(y, mu)[source]

Computes the absolute determinant of the Jacobian.

Parameters:
  • y (Tensor) – Input tensor of shape (batch_size, size).

  • mu (Tensor) – Conditional input of shape (batch_size, conditional_size).

Return type:

Tensor

Returns:

Determinant of shape (batch_size,).

class PeriodicGSymplecticNet(size, conditional_size, width, nb_layers, **kwargs)[source]

Bases: InvertibleNet

An invertible neural network composed of multiple invertible layers.

Parameters:
  • size (int) – dimension of the input data

  • conditional_size (int) – dimension of the conditional input data

  • width (int) – width of the hidden layers in each layer

  • nb_layers (int) – number of invertible layers to compose

  • **kwargs – other arguments for the invertible layers

forward(inputs)[source]

Applies all layers in sequence.

Parameters:

inputs (Tensor) – Input tensor of shape (2,batch_size, size).

Return type:

Tensor

Returns:

Transformed tensor of shape (batch_size, size).

backward(inputs)[source]

Applies all layers in reverse order.

Parameters:

inputs (Tensor) – Input tensor of shape (2, batch_size, size).

Return type:

Tensor

Returns:

Inverse transformed tensor of shape (batch_size, size).

log_abs_det_jacobian(y, mu)[source]

Computes the log absolute determinant of the Jacobian.

Parameters:
  • y (Tensor) – Input tensor of shape (batch_size, size).

  • mu (Tensor) – Conditional input of shape (batch_size, conditional_size).

Return type:

Tensor

Returns:

Log determinant of shape (batch_size,).

abs_det_jacobian(y, mu)[source]

Computes the absolute determinant of the Jacobian.

Parameters:
  • y (Tensor) – Input tensor of shape (batch_size, size).

  • mu (Tensor) – Conditional input of shape (batch_size, conditional_size).

Return type:

Tensor

Returns:

Determinant of shape (batch_size,).

class LASymplecticNet(size, conditional_size, width, nb_layers, **kwargs)[source]

Bases: InvertibleNet

An invertible neural network composed of multiple invertible layers.

Parameters:
  • size (int) – dimension of the input data

  • conditional_size (int) – dimension of the conditional input data

  • width (int) – width of the hidden layers in each layer

  • nb_layers (int) – number of invertible layers to compose

  • **kwargs – other arguments for the invertible layers

log_abs_det_jacobian(y, mu)[source]

Computes the log absolute determinant of the Jacobian.

Parameters:
  • y (Tensor) – Input tensor of shape (batch_size, size).

  • mu (Tensor) – Conditional input of shape (batch_size, conditional_size).

Return type:

Tensor

Returns:

Log determinant of shape (batch_size,).

abs_det_jacobian(y, mu)[source]

Computes the absolute determinant of the Jacobian.

Parameters:
  • y (Tensor) – Input tensor of shape (batch_size, size).

  • mu (Tensor) – Conditional input of shape (batch_size, conditional_size).

Return type:

Tensor

Returns:

Determinant of shape (batch_size,).

class PSymplecticNet(size, conditional_size, deg, nb_layers, **kwargs)[source]

Bases: InvertibleNet

An invertible neural network composed of multiple invertible layers.

Parameters:
  • size (int) – dimension of the input data

  • conditional_size (int) – dimension of the conditional input data

  • deg (int) – degree of the polynomial transformation

  • nb_layers (int) – number of invertible layers to compose

  • **kwargs – other arguments for the invertible layers

log_abs_det_jacobian(y, mu)[source]

Computes the log absolute determinant of the Jacobian.

Parameters:
  • y (Tensor) – Input tensor of shape (batch_size, size).

  • mu (Tensor) – Conditional input of shape (batch_size, conditional_size).

Return type:

Tensor

Returns:

Log determinant of shape (batch_size,).

abs_det_jacobian(y, mu)[source]

Computes the absolute determinant of the Jacobian.

Parameters:
  • y (Tensor) – Input tensor of shape (batch_size, size).

  • mu (Tensor) – Conditional input of shape (batch_size, conditional_size).

Return type:

Tensor

Returns:

Determinant of shape (batch_size,).