Remove deprecated code

The use of Variable() explicitly is deprecated as Autograd now supports tensors directly.
This commit is contained in:
Ayush Chaurasia
2018-05-29 21:02:10 +05:30
committed by GitHub
parent de563d70fd
commit e19eb5d060

View File

@ -17,8 +17,8 @@ x = torch.unsqueeze(torch.linspace(-1, 1, 100), dim=1) # x data (tensor), shape
y = x.pow(2) + 0.2*torch.rand(x.size()) # noisy y data (tensor), shape=(100, 1) y = x.pow(2) + 0.2*torch.rand(x.size()) # noisy y data (tensor), shape=(100, 1)
# torch can only train on Variable, so convert them to Variable # torch can only train on Variable, so convert them to Variable
x, y = Variable(x), Variable(y) #x, y = Variable(x), Variable(y)
#The above code is depricated. Now,autograd directly supports tensors
# plt.scatter(x.data.numpy(), y.data.numpy()) # plt.scatter(x.data.numpy(), y.data.numpy())
# plt.show() # plt.show()
@ -60,4 +60,4 @@ for t in range(100):
plt.pause(0.1) plt.pause(0.1)
plt.ioff() plt.ioff()
plt.show() plt.show()