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:
- property basis#
The POD basis. It is a matrix whose columns are the first
rank
POD modes.- Returns:
The POD basis.
- Return type:
- property scaler#
Return the scaler dictionary, having keys
mean
andstd
corresponding to the mean and the standard deviation of the coefficients, respectively.- Returns:
The scaler dictionary.
- Return type:
- 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:
- 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:
- 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:
- 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: