# Path: tests/context.py

# 
# Path: tests/context.py



import numpy as np
import copy
import pdb
import os
import time
import matplotlib
import matplotlib.pylab as plt
from .context import pep, vfe
from .context import pep_tmp as pep
from test_utils import check_grad
        params = model.init_hypers(y_train)
        obj, grads = model.objective_function(params, N_train, alpha=alpha)

        collapsed_model = vfe.SGPR_collapsed(x_train, y_train, M)
        c_obj, c_grads = collapsed_model.objective_function(params, N_train, alpha=alpha)

        print alpha
        print obj - c_obj
        print obj, c_obj

        for key in c_grads.keys():
            print key
            print grads[key] - c_grads[key]
            print grads[key]
            print c_grads[key]


def test_gpr_pep_probit():
    N_train = 5
    alpha = 0.5
    M = 3
    D = 2
    Q = 3
    x_train = np.random.randn(N_train, D)
    y_train = 2 * np.random.randint(0, 2, size=(N_train, Q)) - 1
    model = pep.SGPR_rank_one(x_train, y_train, M, lik='Probit')
    params = model.init_hypers(y_train)
    print 'gpr aep probit'
    for alpha in np.linspace(0.05, 1, 20):
        print alpha

# Path: tests/context.py

# 
# Path: tests/context.py



# Path: tests/test_grads_pep.py
import numpy as np
import copy
import pdb
import os
import time
import matplotlib
import matplotlib.pylab as plt
from .context import pep, vfe
from .context import pep_tmp as pep
from test_utils import check_grad

        params = model.init_hypers(y_train)
        obj, grads = model.objective_function(params, N_train, alpha=alpha)

        collapsed_model = vfe.SGPR_collapsed(x_train, y_train, M)
        c_obj, c_grads = collapsed_model.objective_function(params, N_train, alpha=alpha)

        print alpha
        print obj - c_obj
        print obj, c_obj

        for key in c_grads.keys():
            print key
            print grads[key] - c_grads[key]
            print grads[key]
            print c_grads[key]


def test_gpr_pep_probit():
    N_train = 5
    alpha = 0.5
    M = 3
    D = 2
    Q = 3
    x_train = np.random.randn(N_train, D)
    y_train = 2 * np.random.randint(0, 2, size=(N_train, Q)) - 1
    model = pep.SGPR_rank_one(x_train, y_train, M, lik='Probit')
    params = model.init_hypers(y_train)
    print 'gpr aep probit'
    for alpha in np.linspace(0.05, 1, 20):
        print alpha

        check_grad(params, model, stochastic=False, alpha=alpha)