[MRD] updates and nicer plotting

This commit is contained in:
Max Zwiessele 2014-11-12 15:08:38 +00:00
parent 74b95d1b69
commit 3c642a5600
6 changed files with 26 additions and 8 deletions

View file

@ -39,6 +39,11 @@ def load(file_path):
:param file_name: path/to/file.pickle
"""
import cPickle as pickle
with open(file_path, 'rb') as f:
m = pickle.load(f)
try:
with open(file_path, 'rb') as f:
m = pickle.load(f)
except:
import pickle as pickle
with open(file_path, 'rb') as f:
m = pickle.load(f)
return m

View file

@ -238,6 +238,10 @@ class Model(Parameterized):
if self.size == 0:
print 'nothing to optimize'
if not self.update_model():
print "setting updates on again"
self.update_model(True)
if start == None:
start = self.optimizer_array
@ -279,10 +283,10 @@ class Model(Parameterized):
Note:-
The gradient is considered correct if the ratio of the analytical
and numerical gradients is within <tolerance> of unity.
The *dF_ratio* indicates the limit of numerical accuracy of numerical gradients.
If it is too small, e.g., smaller than 1e-12, the numerical gradients are usually
not accurate enough for the tests (shown with blue).
The *dF_ratio* indicates the limit of numerical accuracy of numerical gradients.
If it is too small, e.g., smaller than 1e-12, the numerical gradients are usually
not accurate enough for the tests (shown with blue).
"""
x = self.optimizer_array.copy()

View file

@ -131,6 +131,13 @@ class NormalTheta(Transformation):
def __str__(self):
return "theta"
def __getstate__(self):
return [self.mu_indices, self.var_indices]
def __setstate__(self, state):
self.mu_indices = state[0]
self.var_indices = state[1]
class NormalNaturalAntti(NormalTheta):
_instances = []
_logexp = Logexp()

View file

@ -54,6 +54,8 @@ class BayesianGPLVMMiniBatch(SparseGPMiniBatch):
self.variational_prior = NormalPrior()
X = NormalPosterior(X, X_variance)
self.kl_factr = 1.
if inference_method is None:
from ..inference.latent_function_inference.var_dtc import VarDTC
self.logger.debug("creating inference_method var_dtc")

View file

@ -100,7 +100,7 @@ class MRD(BayesianGPLVMMiniBatch):
self.logger.info("building kernels")
if kernel is None:
from ..kern import RBF
kernels = [RBF(input_dim, ARD=1, lengthscale=fracs[i]) for i in range(len(Ylist))]
kernels = [RBF(input_dim, ARD=1, lengthscale=1./fracs[i]) for i in range(len(Ylist))]
elif isinstance(kernel, Kern):
kernels = []
for i in range(len(Ylist)):

View file

@ -162,7 +162,7 @@ def plot_latent(model, labels=None, which_indices=None,
else:
x = X[index, input_1]
y = X[index, input_2]
ax.scatter(x, y, marker=m, s=s, c=Tango.nextMedium(), label=this_label, linewidth=.5, edgecolor='k', alpha=.9)
ax.scatter(x, y, marker=m, s=s, c=Tango.nextMedium(), label=this_label, linewidth=.2, edgecolor='k', alpha=.9)
ax.set_xlabel('latent dimension %i' % input_1)
ax.set_ylabel('latent dimension %i' % input_2)