Example #1
0
    def callback(params, t, g):
        x, y, xy = sample_data(1, n_data, ker=ker)
        preds = hyper_predict(params, x, xy, nn_arch, act)  # [1, nd]
        if plot: p.plot_iter(ax, x[0], x[0], y, preds)

        # cov_compare = np.cov(y.ravel())-np.cov(preds.ravel())
        print("ITER {} | OBJ {} COV DIFF {}".format(t, objective(params, t), 1))
Example #2
0
 def callback(params, t, g):
     y = sample_gpp(x, 1, ker)
     #y=sample_function(x,1)
     preds = hyper_predict(params, x, y, nn_arch, act)  #[1,nd]
     if plot: p.plot_iter(ax, x, x, y, preds)
     cd = np.cov(y.ravel()) - np.cov(preds.ravel())
     print("ITER {} | OBJ {} COV DIFF {}".format(t, objective(params, t),
                                                 cd))
Example #3
0
    def callback(params, t, g):
        plot_inputs = np.linspace(-10, 10, num=500)[:, None]

        f_bnn = sample_bnn(params, plot_inputs, 5, arch, act)
        #print(params[1])
        # Plot data and functions.
        p.plot_iter(ax, inputs, plot_inputs, targets, f_bnn)
        print("ITER {} | LOSS {}".format(t, -loss(params, t)))
Example #4
0
    def callback(params, t, g):
        plot_inputs = np.linspace(-8, 8, num=400)[:, None]
        f_bnn = sample_bnn(params, plot_inputs, 5, arch, act)

        # Plot data and functions.
        p.plot_iter(ax, inputs, plot_inputs, targets, f_bnn)
        print("ITER {} | LOSS {}".format(t, -loss(params, t)))
        if t > 50:
            D = inputs, targets
            x_plot = np.reshape(np.linspace(-8, 8, 400), (400, 1))
            pred = sample_bnn(params, x_plot, 5, arch, act)
            p.plot_deciles(x_plot.ravel(), pred.T, D, str(t) + "bnnpostfullprior", plot="gpp")
Example #5
0
 def callback(params, t, g):
     preds = bnn_predict(params, x, nn_arch, act)[:, :, 0]  #[1,nd]
     #print(preds.shape)
     if plot: plot_iter(ax, x.ravel(), x.ravel(), y, preds[0])
     print("ITER {} | OBJ {}".format(t, objective(params, t)))