How to solve this problem of RUNTIMEERROR

q = torch.arange(0, 20).storage()

x = torch.empty(0).set_(q, storage_offset = 5, size = (3, 2), stride = (4, 1))

when I run this in my local mac python environment of PyTorch(1.0.0),I meet the RuntimeError: Expected object of data type 6 but got data type 4 for argument #2 ‘source’. I don’t know how to solve it. Who can help me? Thank you very much

@MKy I have never seen this error but a fix would be to call .double() on your model (or .float() on the input). I would suggest you to add ‘.float()’ to your input and see

Try writting

q = torch.arange(0, 20).storage().float()
x = torch.empty(0).set_(q, storage_offset = 5, size = (3, 2), stride = (4, 1))

Yeah,I try it by adding the “.float()” to the input, and it works. Good! Thank you, Amrit_Das!:grinning:

1 Like

I’m still confused why my pytorch traceback is the RuntimeError: Expected object of data type 6 but got data type 4 for argument #2 ‘source’. Is there anything wrong with my pytorch?

No there is nothing wrong with your system it is a PyTorch new update bug. :smile: