def _gllim_step(cont: context.abstractHapkeModel, current_noise_cov, current_noise_mean, current_theta): ti = time.time() gllim = jGLLiM(K, sigma_type="full", stopping_ratio=stoppingRatioGLLiM) Xtrain, Ytrain = cont.get_data_training(Ntrain) Ytrain = cont.add_noise_data(Ytrain, covariance=current_noise_cov, mean=current_noise_mean) gllim.fit(Xtrain, Ytrain, current_theta, maxIter=maxIterGlliM) gllim.inversion() logging.debug(f"GLLiM step done in {time.time() -ti:.3f} s") return gllim
def interface_julia(): c = context.HapkeContext() X, Y = c.get_data_training(100000) gllim = jGLLiM(100, sigma_type="full") gllim.init_fit(X, Y, "kmeans") scipy.io.savemat(PATH_OUTPUT, dict(gllim.dict_julia, X=X, Y=Y)) gllim.fit(X, Y, {"rnk": gllim.rnk}, maxIter=10) scipy.io.loadmat(PATH_OUTPUT)
def setup_jGLLiM_GLLiM(): X = np.random.multivariate_normal(np.zeros(5) + 0.2, np.eye(5), 100000) Y = np.random.multivariate_normal(np.zeros(6) + 10, np.eye(6), 100000) gllim = GLLiM(100, 0, sigma_type="full", gamma_type="full", verbose=None) gllim.init_fit(X, Y, None) jgllim = jGLLiM(100, 0, sigma_type="full", gamma_type="full", verbose=None) jgllim.init_fit(X, Y, None) return gllim, jgllim, X, Y
def _init(cont: context.abstractHapkeModel): gllim = jGLLiM(K, sigma_type="full", verbose=False) Xtrain, Ytrain = cont.get_data_training(Ntrain) Ytrain = cont.add_noise_data(Ytrain, covariance=INIT_COV_NOISE, mean=INIT_MEAN_NOISE) # 0 offset m = cont.get_X_uniform(K) rho = np.ones(gllim.K) / gllim.K precisions = init_X_precision_factor * np.array([np.eye(Xtrain.shape[1])] * gllim.K) rnk = gllim._T_GMM_init(Xtrain, 'random', weights_init=rho, means_init=m, precisions_init=precisions) gllim.fit(Xtrain, Ytrain, {"rnk": rnk}, maxIter=1) return gllim.theta
def equivalence_jGLLiM_GLLIM(): h = HapkeContext((0, 1, 2, 3)) X = h.get_X_sampling(2000) Y = np.random.multivariate_normal(np.zeros(10) + 0.4, np.eye(10), 2000) gllim = GLLiM(10, 0, sigma_type="full", gamma_type="full", verbose=False) gllim.init_fit(X, Y, "random") rnk = gllim.rnk init = {"rnk": rnk} gllim.fit(X, Y, init, maxIter=5) jgllim = jGLLiM(10, 0, sigma_type="full", gamma_type="full", verbose=False) jgllim.fit(X, Y, init, maxIter=5) theta = (gllim.pikList, gllim.ckList, gllim.GammakList, gllim.AkList, gllim.bkList, gllim.full_SigmakList) jtheta = (jgllim.pikList, jgllim.ckList, jgllim.GammakList, jgllim.AkList, jgllim.bkList, jgllim.full_SigmakList) is_egal(theta, jtheta)