In [11]:
%load_ext autoreload
%autoreload 2
import sympy as smp
import numpy as np
import scipy.special as sp

import matplotlib
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42

import matplotlib.pyplot as plt
#from matplotlib import animation
%matplotlib inline

import seaborn as sns
color_names = ["windows blue",
               "red",
               "gold",
               "grass green"]
colors = sns.xkcd_palette(color_names)
sns.set_style("white")


The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload

In [12]:
# Load results
ELBO_grep = np.loadtxt('results/grep_gammaDEF_elbo.txt')
ELBO_advi = np.loadtxt('results/faces_elbo_advi.csv')
ELBO_bbvi = np.loadtxt('results/faces_elbo_bbvi.csv')
ELBO_R1 = np.load('results/Olivette_Eta0.75_B4_corrTrue_ELBO.npy')
ELBO_R1 = ELBO_R1[ELBO_R1<0.]

In [13]:
d_advi = 50
d_grep = 25
d_rsvi = 25

# Versus time
max_time = 75000
fig = plt.figure(figsize=(12, 9))
ax = fig.add_subplot(111)

# ADVI
ind = 2.*ELBO_advi[:,0] < max_time
#print np.sum(ind)/d_advi
E_plot = ELBO_advi[ind,:]
ax.semilogx(2.*E_plot[::d_advi,0],E_plot[::d_advi,1], color=colors[3],lw=4, label='$\\mathrm{ADVI}$')

# BBVI
ind = 2.*ELBO_bbvi[:,0] < max_time
#print np.sum(ind)
ax.semilogx(2.*ELBO_bbvi[ind,0],ELBO_bbvi[ind,1], color=colors[2],lw=4, label='$\\mathrm{BBVI}$')

# G-REP
ind = 2.*ELBO_grep[:,1] < max_time
#print np.sum(ind)/d_grep
E_plot = ELBO_grep[ind,:]
ax.semilogx(2.*E_plot[::d_grep,1],E_plot[::d_grep,2], color=colors[0],lw=4, label='$\\mathrm{G-REP}$')

# Rejection
time_rejection = 1. # Relative time versus ELBO_grep
time_vec = time_rejection*np.arange(ELBO_R1.shape[0])+time_rejection
ind = time_vec < max_time
#print np.sum(ind)/d_rsvi
time_vec = time_vec[ind]
E_plot = ELBO_R1[ind]
ax.semilogx(time_vec[::d_rsvi]+1,E_plot[::d_rsvi], color=colors[1],lw=4, label='$\\mathrm{RSVI}$')

ax.grid()
ax.set_ylim(-2.5e7, -0.5e7)
ax.set_xlim(1,max_time)
ax.yaxis.get_offset_text().set_fontsize(16)
ax.tick_params(axis='both', which='major', labelsize=16)
ax.tick_params(axis='both', which='minor', labelsize=16)
ax.set_xlabel("Time $[s]$", fontsize=22)
ax.set_ylabel('$\\mathrm{ELBO}$',fontsize=20)
ax.legend(loc='lower right',fontsize=18)
filename = 'plots/Olivette_time.pdf'
plt.savefig(filename, bbox_inches='tight',dpi=300)



In [ ]:


In [ ]: