mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-15 06:52:39 +02:00
[yak shaving]
This commit is contained in:
parent
ba813edd07
commit
637be86369
3 changed files with 14 additions and 6 deletions
|
|
@ -314,8 +314,8 @@ class Parameterized(Parameterizable):
|
|||
if name in pnames:
|
||||
param = self.parameters[pnames.index(name)]
|
||||
param[:] = val; return
|
||||
except AttributeError:
|
||||
pass
|
||||
except AttributeError as a:
|
||||
raise
|
||||
return object.__setattr__(self, name, val);
|
||||
|
||||
#===========================================================================
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ except ImportError:
|
|||
import pickle
|
||||
|
||||
|
||||
class Metropolis_Hastings:
|
||||
class Metropolis_Hastings(object):
|
||||
def __init__(self,model,cov=None):
|
||||
"""Metropolis Hastings, with tunings according to Gelman et al. """
|
||||
self.model = model
|
||||
|
|
|
|||
|
|
@ -5,15 +5,23 @@ Created on 24 Feb 2014
|
|||
'''
|
||||
|
||||
import numpy as np
|
||||
from GPy.util.pca import PCA
|
||||
from ..util.pca import PCA
|
||||
|
||||
def initialize_latent(init, input_dim, Y):
|
||||
Xr = np.asfortranarray(np.random.randn(Y.shape[0], input_dim))
|
||||
if init == 'PCA':
|
||||
Xr = np.asfortranarray(np.random.normal(0, 1, (Y.shape[0], input_dim)))
|
||||
if 'PCA' in init:
|
||||
p = PCA(Y)
|
||||
PC = p.project(Y, min(input_dim, Y.shape[1]))
|
||||
Xr[:PC.shape[0], :PC.shape[1]] = PC
|
||||
var = .1*p.fracs[:input_dim]
|
||||
elif init in 'empirical_samples':
|
||||
from ..util.linalg import tdot
|
||||
from ..util import diag
|
||||
YYT = tdot(Y)
|
||||
diag.add(YYT, 1e-6)
|
||||
EMP = np.asfortranarray(np.random.multivariate_normal(np.zeros(Y.shape[0]), YYT, min(input_dim, Y.shape[1])).T)
|
||||
Xr[:EMP.shape[0], :EMP.shape[1]] = EMP
|
||||
var = np.random.uniform(0.5, 1.5, input_dim)
|
||||
else:
|
||||
var = Xr.var(0)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue