各种优化器的比较 莫烦的对各种优化通俗理解的视频 import torch import torch.utils.data as Data import torch.nn.functional as F from torch.autograd import Variable import matplotlib.pyplot as plt # 超参数 LR = 0.01 BATCH_SIZE = EPOCH = # 生成假数据 # torch.unsqueeze() 的作用是将一维变二维,torc…
import torch from torch.autograd import Variable import matplotlib.pyplot as plt torch.manual_seed() # fake data x = torch.unsqueeze(torch.linspace(-,,),dim=) y = x.pow() + 0.2 * torch.rand(x.size()) x, y = Variable(x,requires_grad=False), Variable(y…
下面的代码说明个整个神经网络模拟回归的过程,代码含有详细注释,直接贴下来了 import torch from torch.autograd import Variable import torch.nn.functional as F import matplotlib.pyplot as plt #绘制散点图 x=torch.unsqueeze(torch.linspace(-,,),dim=)#x轴共一百个点 y=x.pow()+0.2*torch.rand(x.size())#x^2加上…