Hi, I have a set of K 1-dimensional convolutional filters. I want to convolve them temporally with a matrix Z, which has a shape (batches, time, K). The output should be (batches, time - (filter_length / 2), K), where each output dimension is simply the corresponding input dimension convolved with its respective filter. I want to avoid looping over each of the K dimensions using conv1d - how can I perform the convolution of each input dimension in parallel to save some time? Would conv2d accomplish this?
Based on your description it sounds like you are searching for depthwise convolutions where groups==in_channels
.
From the docs:
groups controls the connections between inputs and outputs. in_channels and out_channels must both be divisible by groups. For example,
At groups=1, all inputs are convolved to all outputs.
At groups=2, the operation becomes equivalent to having two conv layers side by side, each seeing half the input channels and producing half the output channels, and both subsequently concatenated.
At groups= in_channels, each input channel is convolved with its own set of filters (of size out_channelsin_channelsin_channelsout_channels​).