Try the following:
loss = loss_func(output, Variable(y.long()))

When there’s a type-mismatch like this, there might be some misunderstanding around what the functions do. For example, there is a reason why CrossEntropyLoss(input, target) takes LongTensor targets and FloatTensor inputs