How do I squeeze a layer's dimensions down inside of nn.Sequential?

Hi, I have this neural net: = nn.Sequential(
                        nn.Conv2d(in_channels=30, out_channels=1, kernel_size=(1, 1), stride=1),

The input size is 100 rows x 30 columns x 1 x 1. Before passing it through the Linear layer, I need it to be a completely flattened 100 number array. Squeeze() does the trick but I can’t insert it into nn.Sequential for some reason. nn.Flatten() brings it down to 400 x 1 but I need it to be essentially 400 x 0 for it to work.


1 Like

Modifying nn.Flatten() to nn.Flatten(start_dim=0) should work.

1 Like