hunkim / PyTorchZeroToAll

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

Replace deprecated `Variable` class #29

Open fredpolicarpo opened 6 years ago

fredpolicarpo commented 6 years ago

https://github.com/hunkim/PyTorchZeroToAll/blob/edd7ba1f19a8d2e74188d6caf6b020dc20130e53/03_auto_gradient.py#L7

The class torch.autograd.Variable is deprecated.

This line must be updated to

w = torch.tensor([1.0], requires_grad=True) # Any random value

Vermeille commented 5 years ago

I really don't get why everyone is still using Variable. It's deprefuckingcated :laughing:

hchen98 commented 4 years ago

https://github.com/hunkim/PyTorchZeroToAll/blob/edd7ba1f19a8d2e74188d6caf6b020dc20130e53/03_auto_gradient.py#L7

The class torch.autograd.Variable is deprecated.

This line must be updated to

w = torch.tensor([1.0], requires_grad=True) # Any random value

Thanks for the update. It is funny when I code in PyCharm because the IDE suggests the 'w = torch.tensor([1.0], requires_grad=True)' is discouraged...