Solved by zetyquickly in post #2 
              
              
                Hello @Alexandra_Lorenzo 
That error looks very uninformative, I think this is because of quite old version used (# PyTorch v0.4.0). 
What I can see from you code that Linear takes output from Conv2d without any modifications. 
...
x = self.conv7(x)
print('size',x.size())
x = self.fc1(x)
...

This i…