batched_convolution#

pymc_marketing.mmm.transformers.batched_convolution(x, w, *, dim, kernel_dim, mode=ConvMode.After)[source]#

Apply a 1D convolution in a vectorized way across multiple batch dimensions.

(Source code)

Parameters:
xtensor_like

The array to convolve.

wtensor_like

The weight of the convolution.

dim: str

The dimension of the x input along which to perform the convolution.

kernel_dim: str

The dimension of the w input along with to perform the convolution

modeConvMode, optional

The convolution mode determines how the convolution is applied at the boundaries of the input signal, denoted as “x.” The default mode is ConvMode.After.

  • ConvMode.After: Applies the convolution with the “Adstock” effect, resulting in a trailing decay effect.

  • ConvMode.Before: Applies the convolution with the “Excitement” effect, creating a leading effect similar to the wow factor.

  • ConvMode.Overlap: Applies the convolution with both “Pull-Forward” and “Pull-Backward” effects, where the effect overlaps with both preceding and succeeding elements.

Returns:
yXTensorVariable

The result of convolving x with w along the desired dims. The shape of the result will match the shape of x up to broadcasting with w. The convolved axis will show the results of left padding zeros to x while applying the convolutions. x_dim will be present in the returned output.