mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-11 04:52:37 +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
|
Created on 24 Feb 2014
|
||||||
|
|
||||||
@author: maxz
|
@author: maxz
|
||||||
'''
|
"""
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from ..util.pca import PCA
|
from ..util.pca import PCA
|
||||||
|
|
||||||
|
|
||||||
def initialize_latent(init, input_dim, Y):
|
def initialize_latent(init, input_dim, Y):
|
||||||
Xr = np.asfortranarray(np.random.normal(0, 1, (Y.shape[0], input_dim)))
|
Xr = np.asfortranarray(np.random.normal(0, 1, (Y.shape[0], input_dim)))
|
||||||
if 'PCA' in init:
|
if "PCA" == init:
|
||||||
p = PCA(Y)
|
p = PCA(Y)
|
||||||
PC = p.project(Y, min(input_dim, Y.shape[1]))
|
PC = p.project(Y, min(input_dim, Y.shape[1]))
|
||||||
Xr[: PC.shape[0], : PC.shape[1]] = PC
|
Xr[: PC.shape[0], : PC.shape[1]] = PC
|
||||||
var = .1*p.fracs[:input_dim]
|
var = 0.1 * p.fracs[:input_dim]
|
||||||
elif init in 'empirical_samples':
|
elif init == "empirical_samples":
|
||||||
from ..util.linalg import tdot
|
from ..util.linalg import tdot
|
||||||
from ..util import diag
|
from ..util import diag
|
||||||
|
|
||||||
YYT = tdot(Y)
|
YYT = tdot(Y)
|
||||||
diag.add(YYT, 1e-6)
|
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
|
Xr[: EMP.shape[0], : EMP.shape[1]] = EMP
|
||||||
var = np.random.uniform(0.5, 1.5, input_dim)
|
var = np.random.uniform(0.5, 1.5, input_dim)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue