return out net_regr = NeuralNetRegressor( Net(hidden_size=500), max_epochs=5000, lr=0.01, device='cuda', optimizer=torch.optim.Adam, train_split=None, verbose=1, ) res = net_regr.fit(t_d_inp, t_d_oup) # save net_regr.save_params(f_params='step1result') pred = net_regr.predict(test_inp) mse = ((test_oup - pred)**2).mean() print('test error = ' + str(mse)) # plot 1 loss loss = net_regr.history[:, 'train_loss'] plt.figure() plt.plot(loss) plt.ylabel('loss') plt.ylim([0, loss[-1] * 4]) # plot 2 plt.figure() s = 3 plt.scatter(yaxis, pred, s=s, label="Prediction") plt.scatter(yaxis, test_oup, s=s, label="DNS")
resource.setrlimit(resource.RLIMIT_NOFILE, (2048, rlimit[1])) fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11, 4)) print("Fitting") net.fit(train0df, y=None) print("Fit completed") history = net.history train_loss0 = history[:, 'train_loss'] valid_loss0 = history[:, 'valid_loss'] ax1.plot(train_loss0) ax1.plot(valid_loss0) ax1.legend(['train_loss', 'valid_loss']) net.save_params(f_params='dcs0_0005.pkl', f_optimizer='dcs0_0005_optimizer.pkl', f_history='dcs0_0005_history.json') pred = net.predict_proba(valid0) label = valid0.get_label() accuracy = concordance_index(pred, label) print(accuracy) net1 = NeuralNetRegressor(model, criterion=NegativeLogLikelihood, lr=0.00001, batch_size=512, max_epochs=100, optimizer=SGD, optimizer__momentum=0.9, optimizer__weight_decay=0.001,