cs230-stanford / cs230-code-examples

Code examples in pyTorch and Tensorflow for CS230
Other
3.9k stars 996 forks source link

The Variable API has been deprecated in Pytorch 1.10 #43

Open juansulloa opened 3 years ago

juansulloa commented 3 years ago

The Variable API has been deprecated in Pytorch 1.10.

From Pytorch 1.10 documentation: "Autograd automatically supports Tensors with requires_grad set to True Variables are no longer necessary to use autograd with tensors."

The code can be further simplified if lines with Variable calls are removed. For example lines 56-57 of train.pyfile:

# convert to torch Variables
train_batch, labels_batch = Variable(train_batch), Variable(labels_batch)