Have a look at the documentation of CrossEntropyLoss 7.1k.
It states:

It is useful when training a classification problem with C classes.

The error message gives you a hint, that some types are wrong.
You should pass the target as a LongTensor.
Try changing the tgt to:
tgt = torch.autograd.Variable(torch.LongTensor(3).random_(5))