hunkim / PyTorchZeroToAll

Simple PyTorch Tutorials Zero to ALL!
http://bit.ly/PyTorchZeroAll
3.9k stars 1.2k forks source link

Expected object of scalar type Long but got scalar type Float for argument #2 'target' #38

Closed amanpreets01 closed 5 years ago

amanpreets01 commented 5 years ago

I followed the concept given above , took the data,normalized ,split into train and test data and when training ,it says that it want type long but got float32

Any help would be appreciated

jianlianggao commented 5 years ago

You can try to add Variable().long()

amanpreets01 commented 5 years ago

I tried everything .It toggles between float and long When I change the datatype to long it asks float and vice versa i.e. when float then expects long.

I found the solution by the way I just converted the nominal features into one_hot_encode and it worked