meridian.backend.adstock_process

TensorFlow implementation for adstock_process using loop/einsum.

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.

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.

A tensor of shape (..., num_geos, n_times_output, num_channels) representing the adstocked media.