gpr_alpha_examples.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:geepee 作者: thangbui 项目源码 文件源码
def run_regression_1D_aep_two_layers():
    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='L-BFGS-B', 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=-51.385404, test rmse=0.168, ll=0.311
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号