Solved by Nikronic in post #2 
              
              
                Hi, 
The problem is here: 

nn.BatchNorm2d expects 4D inputs in shape of [batch, channel, height, width]. But in the quoted line, you have converted 4D tensor into 2D in shape of [batch, 500] which is not acceptable. 
Using nn.BatchNorm1d will fix the issue. 
self.dense1_bn = nn.BatchNorm1d(500)

Be…