meridian.model.transformers.CenteringAndScalingTransformer
Stay organized with collections
Save and categorize content based on your preferences.
Applies centering and scaling transformations to a tensor.
Inherits From: TensorTransformer
meridian.model.transformers.CenteringAndScalingTransformer(
tensor: tf.Tensor,
population: tf.Tensor,
population_scaling_id: (tf.Tensor | None) = None
)
This class transforms a tensor so each variable has mean zero and standard
deviation one. Optionally, each variable can be scaled by population before
the centering and scaling transformations are applied. The class stores the
mean and standard deviation of each variable.
Args |
tensor
|
A tensor of dimension (n_geos, n_times, n_channel) used to
compute the means and standard deviations.
|
population
|
A tensor of dimension (n_geos,) containing the population of
each geo, used to compute the scale factors.
|
population_scaling_id
|
An optional boolean tensor of dimension
(n_channels,) indicating the variables for which the value will be
scaled by population.
|
Methods
forward
View source
forward(
tensor: tf.Tensor, apply_population_scaling: bool = True
) -> tf.Tensor
Scales a given tensor using the stored coefficients.
Args |
tensor
|
A tensor of dimension (n_geos, n_times, n_channels) to
transform.
|
apply_population_scaling
|
Whether to apply population scaling before the
normalization by means and standard deviations.
|
inverse
View source
inverse(
tensor: tf.Tensor
) -> tf.Tensor
Scales back a given tensor using the stored coefficients.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-07 UTC."],[[["The `CenteringAndScalingTransformer` class transforms a tensor to have zero mean and unit standard deviation for each variable."],["This class can optionally scale each variable by a population value before applying centering and scaling transformations."],["The `forward` method scales a given tensor using pre-computed coefficients."],["The `inverse` method reverses the scaling applied by the `forward` method, using the same stored coefficients."]]],["This content describes a `CenteringAndScalingTransformer` class that transforms a tensor by centering (mean zero) and scaling (standard deviation one) its variables. It takes a tensor, population data, and an optional population scaling ID as input. The class stores the mean and standard deviation. It has two main methods: `forward`, which applies the scaling to a tensor, and `inverse`, which reverses the scaling using the stored coefficients. The transformations can be applied channel-wise with the `population_scaling_id`.\n"]]