加入新推出的
Discord 社区,展开实时讨论,获得同行支持,并直接与 Meridian 团队互动!
meridian.model.transformers.CenteringAndScalingTransformer
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
对张量应用居中和缩放转换。
继承自:TensorTransformer
meridian.model.transformers.CenteringAndScalingTransformer(
tensor: tf.Tensor,
population: tf.Tensor,
population_scaling_id: (tf.Tensor | None) = None
)
此类会转换张量,使每个变量的均值为 0,标准差为 1。在应用居中和缩放转换之前,还可以选择按人口比例缩放每个变量。该类存储每个变量的均值和标准差。
实参 |
tensor
|
一种维度为 (n_geos, n_times, n_channel) 的张量,用于计算均值和标准差。 |
population
|
一种维度为 (n_geos,) 的张量,包含每个地理位置的人口数据,用于计算缩放比例。
|
population_scaling_id
|
一种维度为 (n_channels,) 的可选布尔值张量,用于指明哪些变量的值将按人口比例进行缩放。
|
方法
forward
查看源代码
forward(
tensor: tf.Tensor
) -> tf.Tensor
使用已存储的系数缩放给定张量。
inverse
查看源代码
inverse(
tensor: tf.Tensor
) -> tf.Tensor
使用已存储的系数调回给定张量。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-01-25。
[null,null,["最后更新时间 (UTC):2025-01-25。"],[],["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"],null,[]]