Error in defining loss function of a network

I have the loss function of a classifier defined as follows:

classifier_loss = classifier_criterion(classifier_output, label)

Where classifier_output is a [torch.FloatTensor of size 1x202] and labels is a [torch.LongTensor of size 1x1].
Both of them have been defined as variables.
i am using nn.crossentropyloss, my batch size=1.
I am getting an error as follows:

Traceback (most recent call last):
File “train_finetune_cscrv.py”, line 291, in
train(epoch)
File “train_finetune_cscrv.py”, line 212, in train
classifier_loss = classifier_criterion(classifier_output, label)
File “/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/nn/modules/module.py”, line 224, in call
result = self.forward(*input, **kwargs)
File “/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/nn/modules/loss.py”, line 482, in forward
self.ignore_index)
File “/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/nn/functional.py”, line 746, in cross_entropy
return nll_loss(log_softmax(input), target, weight, size_average, ignore_index)
File “/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/nn/functional.py”, line 672, in nll_loss
return _functions.thnn.NLLLoss.apply(input, target, weight, size_average, ignore_index)
File “/home/iab/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/nn/_functions/thnn/auto.py”, line 47, in forward
output, *ctx.additional_args)
RuntimeError: multi-target not supported at /opt/conda/conda-bld/pytorch_1503966894950/work/torch/lib/THNN/generic/ClassNLLCriterion.c:22

PLEASE HELP !!

The error suggests that your targets vector is not actually 1x1. Are you sure it is?

Hi @richard

I figured it out.
It was of size [1 x 1]. But then I changed it to [1, ].
And it worked !!!

Really weird !!