Join the newly launched
Discord community for real-time discussions, peer support, and direct interaction with the Meridian team!
meridian.model.transformers.MediaTransformer
Stay organized with collections
Save and categorize content based on your preferences.
Contains forward and inverse media transformation methods.
Inherits From: TensorTransformer
meridian.model.transformers.MediaTransformer(
media: meridian.backend.Tensor
,
population: meridian.backend.Tensor
)
This class stores scale factors computed from per-geo medians of the media
data, normalized by the geo population.
Args |
media
|
A tensor of dimension (n_geos, n_media_times, n_media_channels)
containing the media data, used to compute the scale factors.
|
population
|
A tensor of dimension (n_geos,) containing the population of
each geo, used to compute the scale factors.
|
Attributes |
population_scaled_median_m
|
|
Methods
forward
View source
forward(
tensor: meridian.backend.Tensor
) -> meridian.backend.Tensor
Scales a given tensor using the stored scale factors.
inverse
View source
inverse(
tensor: meridian.backend.Tensor
) -> meridian.backend.Tensor
Scales a given tensor using the inversed stored scale factors.
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-08-16 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-08-16 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eMediaTransformer\u003c/code\u003e class manages forward and inverse media transformations, operating on tensors of media data.\u003c/p\u003e\n"],["\u003cp\u003eIt calculates scale factors from per-geo medians of media data, normalizing them by geo population.\u003c/p\u003e\n"],["\u003cp\u003eThe class accepts \u003ccode\u003emedia\u003c/code\u003e and \u003ccode\u003epopulation\u003c/code\u003e tensors as arguments to compute these scale factors, with \u003ccode\u003emedia\u003c/code\u003e having dimensions \u003ccode\u003e(n_geos, n_media_times, n_media_channels)\u003c/code\u003e and \u003ccode\u003epopulation\u003c/code\u003e having \u003ccode\u003e(n_geos,)\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eforward\u003c/code\u003e and \u003ccode\u003einverse\u003c/code\u003e methods apply the stored scale factors and their inverses, respectively, to scale a provided tensor.\u003c/p\u003e\n"]]],[],null,["\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/google/meridian/blob/main/meridian/model/transformers.py#L46-L97) |\n\nContains forward and inverse media transformation methods.\n\nInherits From: [`TensorTransformer`](../../../meridian/model/transformers/TensorTransformer.md) \n\n meridian.model.transformers.MediaTransformer(\n media: tf.Tensor, population: tf.Tensor\n )\n\nThis class stores scale factors computed from per-geo medians of the `media`\ndata, normalized by the geo population.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|--------------|---------------------------------------------------------------------------------------------------------------------------------|\n| `media` | A tensor of dimension `(n_geos, n_media_times, n_media_channels)` containing the media data, used to compute the scale factors. |\n| `population` | A tensor of dimension `(n_geos,)` containing the population of each geo, used to compute the scale factors. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ||\n|------------------------------|---------------|\n| `population_scaled_median_m` | \u003cbr /\u003e \u003cbr /\u003e |\n\n\u003cbr /\u003e\n\nMethods\n\n`forward`\n\n[View source](https://github.com/google/meridian/blob/main/meridian/model/transformers.py#L89-L92) \n\n forward(\n tensor: tf.Tensor\n ) -\u003e tf.Tensor\n\nScales a given tensor using the stored scale factors.\n\n`inverse`\n\n[View source](https://github.com/google/meridian/blob/main/meridian/model/transformers.py#L94-L97) \n\n inverse(\n tensor: tf.Tensor\n ) -\u003e tf.Tensor\n\nScales a given tensor using the inversed stored scale factors."]]