def plot_gplvm_aep_gaussian_stochastic():
N_train = 2000
alpha = 0.5
M = 50
D = 2
Q = 3
y_train = np.random.randn(N_train, Q)
model = aep.SGPLVM(y_train, D, M, lik='Gaussian')
# init hypers, inducing points and q(u) params
params = model.init_hypers(y_train)
logZ, grad_all = model.objective_function(params, N_train, alpha=alpha)
mbs = np.logspace(-2, 0, 10)
reps = 20
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):
objs[i, k] = model.objective_function(
params, no_points, alpha=alpha)[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_aep_gplvm.pdf')
评论列表
文章目录