def run_regression_1D_aep_two_layers_stoc():
np.random.seed(42)
print "create dataset ..."
Xtrain, ytrain, Xtest, ytest = create_dataset()
alpha = 1 # other alpha is not valid here
M = 20
model = aep.SDGPR(Xtrain, ytrain, M, hidden_sizes=[2])
model.optimise(method='adam', alpha=1, maxiter=5000, disp=False)
my, vy = model.predict_y(Xtest)
my = np.reshape(my, ytest.shape)
vy = np.reshape(vy, ytest.shape)
rmse = np.sqrt(np.mean((my - ytest)**2))
ll = np.mean(-0.5 * np.log(2 * np.pi * vy) - 0.5 * (ytest - my)**2 / vy)
nlml, _ = model.objective_function(model.get_hypers(), Xtrain.shape[0], alpha)
print 'alpha=%.3f, train ml=%3f, test rmse=%.3f, ll=%.3f' % (alpha, nlml, rmse, ll)
# plot(model, Xtrain, ytrain)
# plt.show()
# should produce something like this
# alpha=1.000, train ml=-69.444086, test rmse=0.170, ll=0.318
评论列表
文章目录