mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-04-24 20:36:23 +02:00
fix changes made to initializatino in #1078
This commit is contained in:
parent
0c78b17cde
commit
8274d02147
1 changed files with 20 additions and 12 deletions
|
|
@ -13,23 +13,21 @@ def initialize_latent(init, input_dim, Y):
|
|||
"""
|
||||
:param init: initialization method for the latent space, 'PCA' or 'random'
|
||||
"""
|
||||
# dealing with depcrecated initialization method
|
||||
# should be remove along the next major release
|
||||
if init == "empirical_samples":
|
||||
warnings.warn(
|
||||
"Deprecated initialization method 'empirical_samples'. "
|
||||
"Use 'random' instead.",
|
||||
DeprecationWarning,
|
||||
)
|
||||
init == "random"
|
||||
|
||||
Xr = np.asfortranarray(np.random.normal(0, 1, (Y.shape[0], input_dim)))
|
||||
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 = 0.1 * p.fracs[:input_dim]
|
||||
elif init == "random":
|
||||
elif init == "empirical_samples":
|
||||
# dealing with depcrecated initialization method
|
||||
# should be remove along the next major release
|
||||
warnings.warn(
|
||||
"Deprecated initialization method 'empirical_samples'. "
|
||||
"Use 'random' instead.",
|
||||
DeprecationWarning,
|
||||
)
|
||||
|
||||
from ..util.linalg import tdot
|
||||
from ..util import diag
|
||||
|
||||
|
|
@ -42,8 +40,18 @@ def initialize_latent(init, input_dim, Y):
|
|||
)
|
||||
Xr[: EMP.shape[0], : EMP.shape[1]] = EMP
|
||||
var = np.random.uniform(0.5, 1.5, input_dim)
|
||||
else:
|
||||
elif init == "random":
|
||||
var = Xr.var(0)
|
||||
else:
|
||||
# dealing with depcrecated initialization method
|
||||
# should be remove along the next major release
|
||||
warnings.warn(
|
||||
f"{init} is not a valid initialization method."
|
||||
"Supoprt for anything else than 'PCA' or 'random' will be removed in the next major release.",
|
||||
DeprecationWarning,
|
||||
)
|
||||
var = Xr.var(0)
|
||||
|
||||
|
||||
Xr -= Xr.mean(0)
|
||||
Xr /= Xr.std(0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue