The shape mismatch error is raised in self.fc, since the number of features in the incoming activation doesn’t match the in_features in this layer.
You can add a print statement before passing out to self.fc:
        out = out.view(out.size(0), -1)
        print(out.shape)
        out = self.fc(out)

and would see that out has the shape [batch_size, 1568], while self.fc is defined with in_features=16*16*12=3072.
The in_features calculation is wrong, as it should be 7*7*32=1568.
Also, note that Variables are deprecated since PyTorch 0.4 so you can use tensors in newer versions.
Replace the .data[0] usage with item() as well, as it should now raise an error.