Hi,
The problem is here:



 MonIA:

self.fc1=nn.Linear(128 28 28,500)
self.dense1_bn = nn.BatchNorm2d(500)


nn.BatchNorm2d 7 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 25 will fix the issue.
self.dense1_bn = nn.BatchNorm1d(500)

Bests