PyTorch RuntimeError: Expected Long, Got Float - How to Fix
This error message indicates that there is a mismatch between the expected data type and the actual data type in a PyTorch operation.
In this case, it seems that the function is expecting a Long tensor as the second argument, but is instead receiving a Float scalar.
To fix this error, you can convert the Float scalar to a Long tensor using the 'long()' function. For example:
x = torch.tensor([1.0, 2.0, 3.0])
y = torch.tensor([0, 1, 2])
z = torch.dot(x, y.long())
Here, we convert 'y' to a Long tensor using 'y.long()', which allows us to pass it as the second argument to 'torch.dot()'.
原文地址: https://www.cveoy.top/t/topic/nDma 著作权归作者所有。请勿转载和采集!