天天看點

pytorch畫圖

 Linux或者Mac下面才能使用,

因為pytorch目前不支援Windows。

​
# -*- coding: UTF-8 -*-
import torch
from torch.autograd import Variable
import matplotlib.pyplot as plt
x=torch.unsqueeze(torch.linspace(-1,1,100),dim=1)
y=x.pow(3)+0.8*torch.rand(x.size())
x.y=Variable(x),Variable(y)
plt.scatter(x.data.numpy(),y.data.numpy())
plt.show()

​
           

繼續閱讀