cerebralnetworkdev:

I’m just wondering most importantly how a nn.Conv1d can handle variable length sequences


Conv layers can handle variable sized inputs as long as the kernel size is larger than the temporal or spatial size of the input. The output shape will be determined by the kernel size, stride, padding, and dilation as given in the docs 10.



 cerebralnetworkdev:

and how it can replicate the functionality of the MaskedConvolution1D implementation above.


Based on the code it seems you are creating a mask and multiplying it with the output activation of the conv layer. If that’s the case, you could use exactly the same workflow in the forward method of your custom conv layer.