credit.preblock.log#
Classes#
Applies a log transformation with an eps offset to specified variables in a batch dict. |
Module Contents#
- class credit.preblock.log.LogTransform(variables: list[str], data_types: list[str] = None, base: str = 'e', eps: float = 1e-08)#
Bases:
credit.preblock.base.BasePreblockApplies a log transformation with an eps offset to specified variables in a batch dict.
Applies
y = log_base(x + eps) - log_base(eps)so thaty = 0whenx = 0, regardless ofeps. UseExpTransformin the postblock to invert this with matchingbaseandeps. Input values should satisfyx >= -eps; values below this produce NaN silently.Operates on
batch[data_type][source][var_key]for each requesteddata_type(default:["input", "target"]).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: "log_transform" args: variables: - "era5/prognostic/3d/Q" data_types: # optional, defaults to ["input", "target"] - "input" - "target" base: "e" # optional, default "e". Options: "e", "2", "10" eps: 1.0e-8 # optional, default 1e-8 # or transform all variables: type: "log_transform" args: variables: []
- variables#
- variables_expanded = False#
- data_types = ['input', 'target']#
- forward(batch: dict) dict#