# Path: tests/context.py

# 
# Path: tests/context.py



import numpy as np
import copy
import pdb
import pprint
import os
from scipy.optimize import check_grad
from .context import lik
from .context import flatten_dict, unflatten_dict

    # check grad mx
    for a in range(N):
        for b in range(Din):
            vx1 = copy.deepcopy(vx)
            vx1[a, b] = vx1[a, b] + eps
            model.update_hypers(params)
            logZ1, _, _ = model.compute_emission_log_lik_exp(
                mx, vx1, scale)

            vx2 = copy.deepcopy(vx)
            vx2[a, b] = vx2[a, b] - eps
            model.update_hypers(params)
            logZ2, _, _ = model.compute_emission_log_lik_exp(
                mx, vx2, scale)

            dab = (logZ1 - logZ2) / eps / 2
            print('vx n=%d, d=%d, computed=%.5f, numerical=%.5f, diff=%.5f'
                  % (a, b, grad_input['vx'][a, b], dab, (grad_input['vx'][a, b] - dab) / dab))


def test_gauss_emis_limit():

    # generate some datapoints for testing
    N = 5
    alpha = 0.00001
    Dout = 3
    Din = 2
    y_train = np.random.randn(N, Dout)
    # params  tied

# Path: tests/context.py

# 
# Path: tests/context.py



# Path: tests/test_grads_emis.py
import numpy as np
import copy
import pdb
import pprint
import os
from scipy.optimize import check_grad
from .context import lik
from .context import flatten_dict, unflatten_dict


    # check grad mx
    for a in range(N):
        for b in range(Din):
            vx1 = copy.deepcopy(vx)
            vx1[a, b] = vx1[a, b] + eps
            model.update_hypers(params)
            logZ1, _, _ = model.compute_emission_log_lik_exp(
                mx, vx1, scale)

            vx2 = copy.deepcopy(vx)
            vx2[a, b] = vx2[a, b] - eps
            model.update_hypers(params)
            logZ2, _, _ = model.compute_emission_log_lik_exp(
                mx, vx2, scale)

            dab = (logZ1 - logZ2) / eps / 2
            print('vx n=%d, d=%d, computed=%.5f, numerical=%.5f, diff=%.5f'
                  % (a, b, grad_input['vx'][a, b], dab, (grad_input['vx'][a, b] - dab) / dab))


def test_gauss_emis_limit():

    # generate some datapoints for testing
    N = 5
    alpha = 0.00001
    Dout = 3
    Din = 2
    y_train = np.random.randn(N, Dout)
    # params  tied

    model = lik.Gauss_Emis(y_train, Dout, Din)