Thanks for the code.
It looks like this line of code is creating an invalid view:
images = Variable(images.view(-1, 12288).cuda())

Based on the model definition and the training loop, each input should have a shape of [batch_size, 28*28=784].
Also, Variables are deprecated since PyTorch 0.4.0 so you can simply use tensors now.