Based on the error message, it seems the input to self.dense1 has the shape [10, 12800], while the number of input features is defined as 6*6*512=18432.
The layer expects a matching number of input features, so you should change self.dense1 to:
self.dense1 = nn.Linear(12800, 1024)