Could you add a print statement before the usage of fc1 and check the shape of the activation tensor?
print(out.shape)
out = self.fc1(out)

I guess that out.shape doesn’t match the expected input features as 128*28*28*28 so that you might have to adjust this value in self.fc1.