# Path: tests/context.py

# 
# 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 scipy.optimize import check_grad
from .context import vfe
from .context import flatten_dict, unflatten_dict
from .context import PROP_MC, PROP_MM
from test_utils import kink, check_grad
    ax2.set_xscale("log", nonposx='clip')
    plt.savefig('/tmp/probit_stochastic_vfe_gpr.pdf')


def test_dgpr_vfe_gaussian(nat_param=True, stoc=False):
    N_train = 10
    alpha = 1
    M = 5
    D = 2
    Q = 3
    y_train = np.random.randn(N_train, Q)
    x_train = np.random.randn(N_train, D)
    hidden_size = [3, 2]
    # TODO: nat_param
    model = vfe.SDGPR(x_train, y_train, M, hidden_size, lik='Gaussian')
    params = model.init_hypers(y_train)
    print 'dgpr vfe gaussian nat_param %r stoc %r' % (nat_param, stoc)
    check_grad(params, model, stochastic=stoc, alpha=alpha)


def test_dgpr_vfe_probit(nat_param=True, stoc=False):
    N_train = 5
    alpha = 1
    M = 3
    D = 2
    Q = 3
    hidden_size = [3, 2]
    x_train = np.random.randn(N_train, D)
    y_train = 2 * np.random.randint(0, 2, size=(N_train, Q)) - 1
    # TODO: nat_param

# Path: tests/context.py

# 
# Path: tests/context.py

# 
# Path: tests/context.py



# Path: tests/test_grads_vfe.py
import numpy as np
import copy
import pdb
import os
import time
import matplotlib
import matplotlib.pylab as plt
from scipy.optimize import check_grad
from .context import vfe
from .context import flatten_dict, unflatten_dict
from .context import PROP_MC, PROP_MM
from test_utils import kink, check_grad

    ax2.set_xscale("log", nonposx='clip')
    plt.savefig('/tmp/probit_stochastic_vfe_gpr.pdf')


def test_dgpr_vfe_gaussian(nat_param=True, stoc=False):
    N_train = 10
    alpha = 1
    M = 5
    D = 2
    Q = 3
    y_train = np.random.randn(N_train, Q)
    x_train = np.random.randn(N_train, D)
    hidden_size = [3, 2]
    # TODO: nat_param
    model = vfe.SDGPR(x_train, y_train, M, hidden_size, lik='Gaussian')
    params = model.init_hypers(y_train)
    print 'dgpr vfe gaussian nat_param %r stoc %r' % (nat_param, stoc)
    check_grad(params, model, stochastic=stoc, alpha=alpha)


def test_dgpr_vfe_probit(nat_param=True, stoc=False):
    N_train = 5
    alpha = 1
    M = 3
    D = 2
    Q = 3
    hidden_size = [3, 2]
    x_train = np.random.randn(N_train, D)
    y_train = 2 * np.random.randint(0, 2, size=(N_train, Q)) - 1
    # TODO: nat_param

    model = vfe.SDGPR(x_train, y_train, M, hidden_size, lik='Probit')