2021
07-17
07-17
pytorch Dropout过拟合的操作
如下所示:importtorchfromtorch.autogradimportVariableimportmatplotlib.pyplotasplttorch.manual_seed(1)N_SAMPLES=20N_HIDDEN=300#trainingdatax=torch.unsqueeze(torch.linspace(-1,1,N_SAMPLES),1)y=x+0.3*torch.normal(torch.zeros(N_SAMPLES,1),torch.ones(N_SAMPLES,1))x,y=Variable(x),Variable(y)#testdatatest_x=torch.unsqueeze(torch.linspace(-1,1,N_SAMPLES),1)test_y=te...
继续阅读 >