Implement the smoothing of 2D tensor

Greetings,

I have a question about smoothing 2D tensor with the conditions as below

input = (1, 10, 20)

Smoothing should be implemented along the sequence of length of 20 so that there are 10 individual smoothing operations. One more thing is to replicate the first and last values of a sequence (length of 20) like

nn.Conv1d(padding_mode=‘replicate’)

For this, I tried to

input = torch.unsqueeze(input, dim=0)
out = nn.Conv1d(1, 1, kernel_size=(1, 3), padding=(0, 1), padding_mode=‘replicate’, bias=False)(input)

But it doesn’t work with some error.
It can be implemented in either inside of network or outside of network.
I need your help
Thanks

What kind of error are you seeing?
Would you like to apply a specific pre-defined kernel for the “smoothing” operation?
If so, you should be able to define the kernel and apply a grouped convolution to the input.
The functional API would probably be a bit easier than using the nn.Conv2d module.