credit.postblock.square#
Classes#
Inverse of the SqrtTransform preblock: converts sqrt-space values to physical space. |
Module Contents#
- class credit.postblock.square.SquareTransform(variables: list[str], key: str = 'y_processed')#
Bases:
credit.postblock.base.BasePostblockInverse of the SqrtTransform preblock: converts sqrt-space values to physical space.
Inverts
y = sqrt(x)back tox = y^2.Note: values may be slightly negative due to floating-point effects; squaring maps these to small positive numbers. Clamping to zero is intentionally avoided to preserve gradient flow if this postblock is ever connected to a differentiable loss.
variablessupports the same shorthand as the scaler: an empty list transforms every variable; partial paths (e.g."era5/prognostic") expand to all variables under that hierarchy. Expansion happens lazily on the first forward call.Config example:
type: "square_transform" args: variables: - "era5/prognostic/3d/Q" # or inverse-transform all variables: type: "square_transform" args: variables: []
- variables#
- variables_expanded = False#
- key = 'y_processed'#
- forward(batch_dict: dict) dict#