Solved by ptrblck in post #2 
              
              
                The unsqueeze was necessary, as your channel dimension was missing. 
Since you are using an image, you should also use nn.MaxPool2d instead of nn.MaxPool1d. 
Here is a small example: 
model = nn.Sequential(
    nn.Conv2d(in_channels=1, out_channels=3, kernel_size=3, stride=1, padding=1),
    nn.MaxP…