UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number
train_loss += loss.data[0]
so transforming the 'train_loss += loss.data[0] ’ into 'train_loss+=loss.item() ’ in the ‘train.py:200’ can fix the warning on the new pytorch version.