Most likely this error is raised in:
loss = criterion(output, labels)

if you try to pass labels as a FloatTensor, while a LongTensor is expected.
Try to use:
loss = criterion(output, labels.long())

instead.