. torch.nn.functional.conv1d padding like torch.nn.Conv1d

I would like to use torch.nn.functional.conv1d to implement filtering.

I noticed that, unlike torch.nn.Conv1d, padding for torch.nn.functional.conv1d does not support 'reflect' , 'replicate' or 'circular' modes (so called padding_mode).

Is there a way around this?

You could use the functional API via F.pad, which accepts the padding_mode argument and which is in fact also done internally in the nn.Conv1d module.

1 Like

You mean to pad the signal before using torch.nn.functional.conv1d. This would work, thanks. I will still need to remove the padding after filtering as I need the exact indices of each point in the signal. Was too lazy to do it, seems this is the only way for now.