# 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

np.random.seed(42)

def test_gpr_pep_gaussian():
    N_train = 20
    M = 5
    D = 2
    Q = 3
    y_train = np.random.randn(N_train, Q)
    x_train = np.random.randn(N_train, D)
    model = pep.SGPR_rank_one(x_train, y_train, M, lik='Gaussian')
    params = model.init_hypers(y_train)
    print 'gpr pep gaussian'
    for alpha in np.linspace(0.05, 1, 20):
        print alpha
        check_grad(params, model, stochastic=False, alpha=alpha)

def compared_gpr_aep_gaussian_collapsed():
    # make sure that the number of pep sweeps is large in the pep model
    N_train = 20
    M = 10
    D = 1
    Q = 1
    for alpha in np.linspace(0.05, 1, 5):
        y_train = np.random.randn(N_train, Q)
        x_train = np.random.randn(N_train, D)
        model = pep.SGPR_rank_one(x_train, y_train, M, lik='Gaussian')
        params = model.init_hypers(y_train)
        obj, grads = model.objective_function(params, N_train, alpha=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


np.random.seed(42)

def test_gpr_pep_gaussian():
    N_train = 20
    M = 5
    D = 2
    Q = 3
    y_train = np.random.randn(N_train, Q)
    x_train = np.random.randn(N_train, D)
    model = pep.SGPR_rank_one(x_train, y_train, M, lik='Gaussian')
    params = model.init_hypers(y_train)
    print 'gpr pep gaussian'
    for alpha in np.linspace(0.05, 1, 20):
        print alpha
        check_grad(params, model, stochastic=False, alpha=alpha)

def compared_gpr_aep_gaussian_collapsed():
    # make sure that the number of pep sweeps is large in the pep model
    N_train = 20
    M = 10
    D = 1
    Q = 1
    for alpha in np.linspace(0.05, 1, 5):
        y_train = np.random.randn(N_train, Q)
        x_train = np.random.randn(N_train, D)
        model = pep.SGPR_rank_one(x_train, y_train, M, lik='Gaussian')
        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)