Facing RuntimeError: invalid argument 3: sizes do not match

My loss function is NLL loss,which takes in as inputs [108416, 3] and targets as [108416] and i get a resulting loss value of 2.2623 , but after the loss computation when i do the optimizer.step() call. I get

AND THIS IS LOSS Variable containing:
 2.2623
[torch.cuda.FloatTensor of size 1 (GPU 0)]

Traceback (most recent call last):
  File "/mnt/sdc1/project/training/fpr4x_liver_1x_2channel.py", line 336, in <module>
train_fpr4x_liver_1x_2channel_model()
  File "/mnt/sdc1/project/training/fpr4x_liver_1x_2channel.py", line 245, in train_fpr4x_liver_1x_2channel_model
est.run_experiment(opts.num_epochs, 5000,50)
  File "/media/redible/sdc/project/training/expt_utils.py", line 236, in run_experiment
self.trainer.train()
  File "/media/redible/sdc/project/training/expt_utils.py", line 75, in train
loss, outputs = self.net_mgr._forward_backward(network_inputs, loss_inputs)
  File "/media/redible/sdc/project/training/network_manager.py", line 19, in _forward_backward
self.optimizer.step()
  File "/usr/local/lib/python3.5/dist-packages/torch/optim/adam.py", line 69, in step
exp_avg.mul_(beta1).add_(1 - beta1, grad)
RuntimeError: invalid argument 3: sizes do not match at /pytorch/torch/lib/THC/generated/../generic/THCTensorMathPointwise.cu:271

Not sure whats the cause of the error any help would be appreciated,Thanks in advance.

Is your code running fine on the CPU?

sorry for the late reply, i was a bit caught up, I have fixed this issue the problem turned out to the resume training part of code,which was linking to a different model path , and thats why i was getting sizes dont match.

But anyways thank you for your time.