Proper Orthogonal Decomposition Block#

class PODBlock(rank, scale_coefficients=True)[source]#

Bases: Module

Proper Orthogonal Decomposition block.

This block projects the input field on the proper orthogonal decomposition basis. Before being used, it must be fitted to the data with the fit method, which invokes the singular value decomposition. This block is not trainable.

Note

All the POD modes are stored in memory, avoiding to recompute them when the rank changes, leading to increased memory usage.

Initialization of the PODBlock class.

Parameters:
  • rank (int) – The rank of the POD layer.

  • scale_coefficients (bool) – If True, the coefficients are scaled after the projection to have zero mean and unit variance. Default is True.

property rank#

The rank of the POD layer.

Returns:

The rank of the POD layer.

Return type:

int

property basis#

The POD basis. It is a matrix whose columns are the first rank POD modes.

Returns:

The POD basis.

Return type:

torch.Tensor

property scaler#

Return the scaler dictionary, having keys mean and std corresponding to the mean and the standard deviation of the coefficients, respectively.

Returns:

The scaler dictionary.

Return type:

dict

property scale_coefficients#

The flag indicating if the coefficients are scaled after the projection.

Returns:

The flag indicating if the coefficients are scaled.

Return type:

bool

fit(X, randomized=True)[source]#

Set the POD basis by performing the singular value decomposition of the given tensor. If self.scale_coefficients is True, the coefficients are scaled after the projection to have zero mean and unit variance.

Parameters:

X (torch.Tensor) – The input tensor to be reduced.

forward(X)[source]#

The forward pass of the POD layer.

Parameters:

X (torch.Tensor) – The input tensor to be reduced.

Returns:

The reduced tensor.

Return type:

torch.Tensor

reduce(X)[source]#

Reduce the input tensor to its POD representation. The POD layer must be fitted before being used.

Parameters:

X (torch.Tensor) – The input tensor to be reduced.

Raises:

RuntimeError – If the POD layer is not fitted.

Returns:

The reduced tensor.

Return type:

torch.Tensor

expand(coeff)[source]#

Expand the given coefficients to the original space. The POD layer needs to be fitted before being used.

Parameters:

coeff (torch.Tensor) – The coefficients to be expanded.

Raises:

RuntimeError – If the POD layer is not fitted.

Returns:

The expanded tensor.

Return type:

torch.Tensor