basisconv2d#

hypercoil.functional.tsconv.basisconv2d(X: Tensor, weight: Tensor, basis_functions: Sequence[Callable], include_const: bool = False, bias: Tensor | None = None, padding: Tuple[int, int] | None = None, conv_fn: Callable | None = None, **params) Tensor[source]#

Perform convolution using basis function channel mapping.

Convolution using a kernel whose ith input channel evaluates the ith basis function over the input dataset.

Dimension:
Input : \((N, *, C, obs)\)

N denotes batch size, * denotes any number of intervening dimensions, C denotes number of data channels or variables, obs denotes number of observations per channel.

Weight : \((C_o, K, *, C\ \mathrm{or}\ 1, R)\)

\(C_o\) denotes number of output channels, K denotes number of input channels (equivalent to the maximum degree of the polynomial), and R < obs denotes the number of observations viewed at once (i.e., in a single convolutional window)

Output : \((N, C_o, *, C, obs)\)

As above.

Parameters:
XTensor

Input dataset to the basis functions. The last two dimensions are seen by each kernel channel. For time series data, these could be variables and sequential observations.

weightTensor

Basis convolution kernel. The first dimension corresponds to the output channels and the second to the input channels, each of which corresponds to the evaluation of a basis function over X. The final dimension corresponds to the number of observations convolved together. For a time series, this corresponds to R // 2 past frames, R // 2 future frames, and the current frame. For a time series, the penultimate dimension determines whether the same convolution is applied to all variables (if it is 1) or variable-specific convolutions can be learned (if it is equal to the number of variables). To permit some diversity in kernels while enforcing consistency across variables, it is possible to penalise a measure of spread such as the variance across the variable axis.

include_constbool (default False)

Indicates that a constant or intercept term should be included. The first channel of the weight sees the constant term.

biasTensor or None

Bias term for convolution. See torch.conv2d documentation for details.

padding2-tuple or None

Padding for convolution, as for torch.conv2d. If not explicitly specified, this will default to 'time series' padding: no padding in the penultimate axis, and R // 2 in the final axis.

**params

Additional parameters can be passed to torch.conv2d.

Returns:
Tensor

Input dataset transformed via basis channel convolution.