# 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
        start_time = time.time()
        for k in range(reps):
            print '%d/%d, %d/%d' % (i, len(mbs), k, reps)
            objs[i, k] = model.objective_function(
                params, no_points, alpha=alpha, prop_mode=PROP_MM)[0]
        times[i] = time.time() - start_time

    f, (ax1, ax2) = plt.subplots(1, 2, figsize=(16, 6))
    ax1.plot(mbs, times, 'x-')
    ax1.set_xlabel("Minibatch proportion")
    ax1.set_ylabel("Time taken")
    ax1.set_xscale("log", nonposx='clip')

    ax2.plot(mbs, objs, 'kx')
    ax2.axhline(logZ, color='b')
    ax2.set_xlabel("Minibatch proportion")
    ax2.set_ylabel("ELBO estimates")
    ax2.set_xscale("log", nonposx='clip')
    plt.savefig('/tmp/gaussian_stochastic_vfe_gpssm_linear_MM.pdf')

    # init hypers, inducing points and q(u) params
    logZ, grad_all = model.objective_function(params, N_train)
    times = np.zeros(len(mbs))
    objs = np.zeros((len(mbs), reps))
    for i, mb in enumerate(mbs):
        no_points = int(N_train * mb)
        start_time = time.time()
        for k in range(reps):
            print '%d/%d, %d/%d' % (i, len(mbs), k, reps)
            objs[i, k] = model.objective_function(

# 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

        start_time = time.time()
        for k in range(reps):
            print '%d/%d, %d/%d' % (i, len(mbs), k, reps)
            objs[i, k] = model.objective_function(
                params, no_points, alpha=alpha, prop_mode=PROP_MM)[0]
        times[i] = time.time() - start_time

    f, (ax1, ax2) = plt.subplots(1, 2, figsize=(16, 6))
    ax1.plot(mbs, times, 'x-')
    ax1.set_xlabel("Minibatch proportion")
    ax1.set_ylabel("Time taken")
    ax1.set_xscale("log", nonposx='clip')

    ax2.plot(mbs, objs, 'kx')
    ax2.axhline(logZ, color='b')
    ax2.set_xlabel("Minibatch proportion")
    ax2.set_ylabel("ELBO estimates")
    ax2.set_xscale("log", nonposx='clip')
    plt.savefig('/tmp/gaussian_stochastic_vfe_gpssm_linear_MM.pdf')

    # init hypers, inducing points and q(u) params
    logZ, grad_all = model.objective_function(params, N_train)
    times = np.zeros(len(mbs))
    objs = np.zeros((len(mbs), reps))
    for i, mb in enumerate(mbs):
        no_points = int(N_train * mb)
        start_time = time.time()
        for k in range(reps):
            print '%d/%d, %d/%d' % (i, len(mbs), k, reps)
            objs[i, k] = model.objective_function(

                params, no_points, alpha=alpha, prop_mode=PROP_MC)[0]