torch tensor type conversion?

Good morning,

In the process of obtaining the following loss, Expected object of type torch.cuda.FloatTensor but found type torch.cuda.LongTensor for argument # 3 'other error occurred.
So I tried to do type conversion in various ways such as N = N.float () or N = N.type (torch.cuda.FloatTensor), and this is one of the variables needed for an inplace operation error Occurs.

loss_l, loss_c: torch.cuda.FloatTensor
N: torch.cuda.LongTensor.

loss_l / = N
loss_c / = N

Can anybody help? Thank you in advance for your time.

Could you try to change your code to:

loss_l = loss_l / N
loss_c = loss_c / N

You should keep your type conversion as torch.cuda.

Thank you for answer.!