# 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 aep
from .context import flatten_dict, unflatten_dict
from .context import PROP_MC, PROP_MM, PROP_LIN
from test_utils import kink, check_grad
def test_dgprh_aep_gaussian(nat_param=True, stoc=False):
    N_train = 10
    alpha = 0.5
    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]
    model = aep.SDGPR_H(x_train, y_train, M, hidden_size, lik='Gaussian')
    params = model.init_hypers(y_train)
    print 'dgprh aep gaussian nat_param %r stoc %r' % (nat_param, stoc)
    check_grad(params, model, stochastic=stoc, alpha=alpha)


def test_dgprh_aep_probit(nat_param=True, stoc=False):
    N_train = 5
    alpha = 0.3
    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
    model = aep.SDGPR_H(x_train, y_train, M, hidden_size, lik='Probit')
    params = model.init_hypers(y_train)
    print 'dgprh aep probit nat_param %r stoc %r' % (nat_param, stoc)
    check_grad(params, model, stochastic=stoc, alpha=alpha)



# Path: tests/context.py

# 
# Path: tests/context.py

# 
# Path: tests/context.py



# Path: tests/test_grads_aep.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 aep
from .context import flatten_dict, unflatten_dict
from .context import PROP_MC, PROP_MM, PROP_LIN
from test_utils import kink, check_grad

def test_dgprh_aep_gaussian(nat_param=True, stoc=False):
    N_train = 10
    alpha = 0.5
    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]
    model = aep.SDGPR_H(x_train, y_train, M, hidden_size, lik='Gaussian')
    params = model.init_hypers(y_train)
    print 'dgprh aep gaussian nat_param %r stoc %r' % (nat_param, stoc)
    check_grad(params, model, stochastic=stoc, alpha=alpha)


def test_dgprh_aep_probit(nat_param=True, stoc=False):
    N_train = 5
    alpha = 0.3
    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
    model = aep.SDGPR_H(x_train, y_train, M, hidden_size, lik='Probit')
    params = model.init_hypers(y_train)
    print 'dgprh aep probit nat_param %r stoc %r' % (nat_param, stoc)
    check_grad(params, model, stochastic=stoc, alpha=alpha)



def test_gpssm_linear_aep_gaussian_kink(nat_param=True, stoc=False, prop_mode=PROP_MM):