RuntimeError('dot : expected both vectors to have same dtype, but found Double and Float

I am trying to perform this operation:

L_c += 1 - torch.abs(torch.dot(nuNormalized, Nu))

where:

nuNormalized → tensor([ 0.3790, -0.4208, 0.8242], dtype=torch.float64)
Nu → tensor([-0.9961, -0.9961, -0.9961], device=‘cuda:0’)

I am getting this error:

(<class ‘RuntimeError’>, RuntimeError(‘dot : expected both vectors to have same dtype, but found Double and Float’,), <traceback object at 0x7f4d276155c8>)

Any suggestions please? Thanks!

You could try converting Nu to float using this:

L_c += 1 - torch.abs(torch.dot(nuNormalized, Nu.float()))

Hi @Dwight_Foster Thanks for helping.
Were you suggesting nuNormalized.float()?

No it says nuNormalized is already a float. I was talking about just Nu. Looking at it now though what is the type of L_c that might be the problem. If that is a double then you may have to do

L_c += 1 - torch.abs(torch.dot(nuNormalized, Nu)).double()

@Dwight_Foster , I tried:

L_c += 1 - torch.abs(torch.dot(nuNormalized, Nu)).double()

I am getting:

RuntimeError: dot : expected both vectors to have same dtype, but found Double and Float

Try this:

L_c += 1 - torch.abs(torch.dot(nuNormalized, Nu.float()))

If that does not work can you print out the type of both of those just doing this

print(nuNormalized.type(), Nu.type())