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.
- 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
- mode
ConvMode, 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:
- y
XTensorVariable The result of convolving
xwithwalong the desired dims. The shape of the result will match the shape ofxup to broadcasting withw. The convolved axis will show the results of left padding zeros toxwhile applying the convolutions.x_dimwill be present in the returned output.
- y