PODBlock#

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

Bases: Module

POD layer: it projects the input field on the proper orthogonal decomposition basis. It needs to be fitted to the data before being used with the method fit(), which invokes the singular value decomposition. The layer is not trainable.

Note

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

Build the POD layer with the given rank.

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.

property rank#

The rank of the POD layer.

Return type:

int

property basis#

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

Return type:

torch.Tensor

property scaler#

The scaler. It is a dictionary with the keys ‘mean’ and ‘std’ that store the mean and the standard deviation of the coefficients.

Return type:

dict

property scale_coefficients#

If True, the coefficients are scaled after the projection to have zero mean and unit variance.

Return type:

bool

fit(X)[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 tensor to be reduced.

forward(X)[source]#

The forward pass of the POD layer. By default it executes the reduce() method, reducing the input tensor to its POD representation. The POD layer needs to be fitted before being used.

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 needs to be fitted before being used.

Parameters:

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

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.

Returns:

The expanded tensor.

Return type:

torch.Tensor