差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
pytorch:regression [2022/06/02 13:49] watalupytorch:regression [2022/06/02 13:56] (現在) watalu
行 75: 行 75:
  
 model = Net(cols, size_hidden, n_output) model = Net(cols, size_hidden, n_output)
-optimizer = torch.optim.Adam(net.parameters(), lr=learning_rate)+optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate)
 criterion = torch.nn.MSELoss(reduction='sum') criterion = torch.nn.MSELoss(reduction='sum')
 </code> </code>
行 119: 行 119:
 ax.plot(loss_train_history, color="blue") ax.plot(loss_train_history, color="blue")
 ax.plot(loss_test_history, color="red") ax.plot(loss_test_history, color="red")
 +plt.show()
 +fig, ax = plt.subplots()
 +ax.plot(loss_train_history, color="blue")
 +ax.plot(loss_test_history, color="red")
 +plt.ylim(0, 8000)
 +plt.show()
 +plt.plot(loss_test_records)
 plt.show() plt.show()
  
行 127: 行 134:
 pred=result.data[:,0].numpy() pred=result.data[:,0].numpy()
 print(len(pred),len(y_train)) print(len(pred),len(y_train))
-r2_score(pred,y_train)+print(r2_score(pred,y_train))
  
 X = Variable(torch.FloatTensor(X_test))  X = Variable(torch.FloatTensor(X_test)) 
行 133: 行 140:
 pred=result.data[:,0].numpy() pred=result.data[:,0].numpy()
 print(len(pred),len(y_test)) print(len(pred),len(y_test))
-r2_score(pred,y_test)+print(r2_score(pred,y_test))
 </code> </code>