You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In investigating CNNs, I have copied an online script into Jupyter Notebook (setup works fine) but:
defining the number of epochs
n_epochs = 25
empty list to store training losses
train_losses = []
empty list to store validation losses
val_losses = []
training the model
for epoch in range(n_epochs):
print('train for epoch:', epoch)
train(epoch)
At the first call to train(epoch) a runtime error is caused:
Line 2846 of ~\anaconda3\lib\site-packages\torch\nn\functional.py in cross_entropy(input, target, weight, size_average, ignore_index, reduce, reduction, label_smoothing)
results in > RuntimeError: expected scalar type Long but found Int
The above is called from line 1150 of ~\anaconda3\lib\site-packages\torch\nn\modules\loss.py in forward(self, input, target) which in turn is called from line 1102 of ~\anaconda3\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
Should I report this to the supplier of the online CNN example or have I discovered a bug?
The text was updated successfully, but these errors were encountered:
RamseyThomson
changed the title
Jupyter Notebook (python version 3.9.0) > RuntimeError: expected scalar type Long but found Int
Jupyter Notebook (python version 3.9.0) PyTorch > RuntimeError: expected scalar type Long but found Int
Mar 26, 2022
In investigating CNNs, I have copied an online script into Jupyter Notebook (setup works fine) but:
defining the number of epochs
n_epochs = 25
empty list to store training losses
train_losses = []
empty list to store validation losses
val_losses = []
training the model
for epoch in range(n_epochs):
print('train for epoch:', epoch)
train(epoch)
At the first call to train(epoch) a runtime error is caused:
Line 2846 of ~\anaconda3\lib\site-packages\torch\nn\functional.py in cross_entropy(input, target, weight, size_average, ignore_index, reduce, reduction, label_smoothing)
results in > RuntimeError: expected scalar type Long but found Int
The above is called from line 1150 of ~\anaconda3\lib\site-packages\torch\nn\modules\loss.py in forward(self, input, target) which in turn is called from line 1102 of ~\anaconda3\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
Should I report this to the supplier of the online CNN example or have I discovered a bug?
The text was updated successfully, but these errors were encountered: