meridian.backend.adstock_process
Stay organized with collections
Save and categorize content based on your preferences.
TensorFlow implementation for adstock_process using loop/einsum.
meridian.backend.adstock_process(
media: '_tf.Tensor', weights: '_tf.Tensor', n_times_output: int
) -> '_tf.Tensor'
This function applies an adstock process to media spend data. It achieves
this by creating a windowed view of the media tensor and then using
tf.einsum to efficiently compute the weighted sum based on the provided
weights. The weights tensor defines the decay effect over a specific
window_size. The output is truncated to n_times_output periods.
Args |
media
|
Input media tensor. Expected shape is (..., num_geos,
num_times_in, num_channels). The ... represents optional batch
dimensions.
|
weights
|
Adstock weights tensor. Expected shape is (..., num_channels,
window_size). The batch dimensions must be broadcast-compatible with
those in media.
|
n_times_output
|
The number of time periods to output. This should be less
than or equal to num_times_in - window_size + 1.
|
Returns |
A tensor of shape (..., num_geos, n_times_output, num_channels)
representing the adstocked media.
|
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 2026-03-05 UTC.
[null,null,["Last updated 2026-03-05 UTC."],[],[]]