mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-10 20:42:39 +02:00
update string checks in initialization.py
This commit is contained in:
parent
bfa1d67fda
commit
92fb49d001
1 changed files with 15 additions and 9 deletions
|
|
@ -1,25 +1,31 @@
|
|||
'''
|
||||
"""
|
||||
Created on 24 Feb 2014
|
||||
|
||||
@author: maxz
|
||||
'''
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
from ..util.pca import PCA
|
||||
|
||||
|
||||
def initialize_latent(init, input_dim, Y):
|
||||
Xr = np.asfortranarray(np.random.normal(0, 1, (Y.shape[0], input_dim)))
|
||||
if 'PCA' in init:
|
||||
if "PCA" == 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':
|
||||
var = 0.1 * p.fracs[:input_dim]
|
||||
elif init == "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)
|
||||
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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue