Problems with implementing a neural network. From Keras to Pytorch

Hi,

Something that I am sure is wrong is that in your Keras code you have 64 as number of filters in Conv layer but I cannot see this number in PyTorch equivalent.
I think you might need to replace it with nn.Conv1d(in_channel=6, out_channel=64, kernel_size=2).

In PyTorch, we just need to determine in/out channels (number of input and output filters), shapes will be captured by PyTorch itself.

Another issue is that you need to add nn.ReLU() between two linear layers. Activation functions in PyTorch can be used like a separate layer.

Furthermore, I am not sure about your data, but you might need to check which dimension corresponds to features or temporal/spatial dims.
For this, you can follow this thread:
Understanding Convolution 1D output and Input - PyTorch Forums

Last 4 replies literally discusses a numerical example.

Bests

1 Like