Static conv operation in pytorch

I want to make conv1d with static mask in pytorch (without learning anything). How could I do that?

I suppose the easiest way would be to use the functional form of conv1d.

Basically in your forward method you would do something like this

output = torch.nn.functional.conv1d(input, static_mask)

Thanks man I just found it by myself) Pytorch documentation…

In troch.nn.functional.conv1d

    if input is not None and input.dim() != 3:
        raise ValueError("Expected 3D tensor as input, got {}D tensor instead.".format(input.dim()))

Not a big deal but conv1d requires all arguments to be variables but why?

Your question doesn’t match the line of code you quoted.
A 1D conv needs input of shape (batches, channels, seq_len).

To answer your question: conv1d expects you to want to be able to calculate gradients, and PyTorch only builds computation graphs for operations involving Variables. Without the computation graph PyTorch can’t calculate gradients, hence the need for Variables.

For my current case loss function evaluates 1-dim vector for whole batch

I am starting to get very confused. Any chance you could show some actual code?