You could print the shapes via:
output = model(input)
print(output.shape)
print(target.shape)
loss = criterion(output, target)

If you are seeing the same error message, the target tensor might be empty.
Feel free to post your training code, so that we can have a look, if you get stuck.