Initializes the covariance matrix with a guess at
        the GP kernel parameters.
979076
def init_kernel(self):
        '''
        

        '''

        if self.kernel_params is None:
            X = self.apply_mask(self.fpix / self.flux.reshape(-1, 1))
            y = self.apply_mask(self.flux) - np.dot(X, np.linalg.solve(
                np.dot(X.T, X), np.dot(X.T, self.apply_mask(self.flux))))
            white = np.nanmedian([np.nanstd(c) for c in Chunks(y, 13)])
            amp = self.gp_factor * np.nanstd(y)
            tau = 30.0
            if self.kernel == 'Basic':
                self.kernel_params = [white, amp, tau]
            elif self.kernel == 'QuasiPeriodic':
                self.kernel_params = [white, amp, 1., 20.]
811708
def _create_model(self, X, Y):
        

        # --- define kernel
        self.input_dim = X.shape[1]
        if self.kernel is None:
            kern = GPy.kern.RBF(self.input_dim, variance=1.)
        else:
            kern = self.kernel
            self.kernel = None

        # --- define model
        noise_var = Y.var()*0.01 if self.noise_var is None else self.noise_var
        self.model = GPy.models.GPRegression(X, Y, kernel=kern, noise_var=noise_var)

        # --- Define prior on the hyper-parameters for the kernel (for integrated acquisitions)
        self.model.kern.set_prior(GPy.priors.Gamma.from_EV(2.,4.))
        self.model.likelihood.variance.set_prior(GPy.priors.Gamma.from_EV(2.,4.))

        # --- Restrict variance if exact evaluations of the objective
        if self.exact_feval:
            self.model.Gaussian_noise.constrain_fixed(1e-6, warning=False)
        else:
            self.model.Gaussian_noise.constrain_positive(warning=False)
1361461
def eighCovarianceMatrix(cfile):
    
    # precompute eigenvalue decomposition
    K = np.loadtxt(cfile+'.cov')
    K+= 1e-4*sp.eye(K.shape[0])
    S,U = la.eigh(K); S=S[::-1]; U=U[:,::-1]
    np.savetxt(cfile+'.cov.eval',S,fmt='%.6f')
    np.savetxt(cfile+'.cov.evec',U,fmt='%.6f')
823374
private void initParams() {
		nbActives = graph.getNodes().size();
		for (int i = 0; i < nbNodes; i++) {
			successors[i] = graph.getSuccOf(i);
			dfsNumberOfNode[i] = -1;
			father[i] = -1;
			A[i] = -1;
		}
	}
770538
def _calc_covar_matrix(self, profile):
        
        corr = self._calc_corr(profile)
        std = self._calc_ln_std(profile)
        # Modify the standard deviation by the truncated norm scale
        std *= randnorm.scale

        var = std ** 2
        covar = corr * std[:-1] * std[1:]

        # Main diagonal is the variance
        mat = diags([covar, var, covar], [-1, 0, 1]).toarray()

        return mat
509936
def create_model(samples_x, samples_y_aggregation,
                 n_restarts_optimizer=250, is_white_kernel=False):
    '''
    
    '''
    kernel = gp.kernels.ConstantKernel(constant_value=1,
                                       constant_value_bounds=(1e-12, 1e12)) * \
                                                gp.kernels.Matern(nu=1.5)
    if is_white_kernel is True:
        kernel += gp.kernels.WhiteKernel(noise_level=1, noise_level_bounds=(1e-12, 1e12))
    regressor = gp.GaussianProcessRegressor(kernel=kernel,
                                            n_restarts_optimizer=n_restarts_optimizer,
                                            normalize_y=True,
                                            alpha=1e-10)
    regressor.fit(numpy.array(samples_x), numpy.array(samples_y_aggregation))

    model = {}
    model['model'] = regressor
    model['kernel_prior'] = str(kernel)
    model['kernel_posterior'] = str(regressor.kernel_)
    model['model_loglikelihood'] = regressor.log_marginal_likelihood(regressor.kernel_.theta)

    return model
937152
def initialize(self):
        
        self.randomize()
        self.dweight = Numeric.zeros(self.size, 'f')
        self.delta = Numeric.zeros(self.size, 'f')
        self.wed = Numeric.zeros(self.size, 'f')
        self.wedLast = Numeric.zeros(self.size, 'f')
        self.target = Numeric.zeros(self.size, 'f')
        self.error = Numeric.zeros(self.size, 'f')
        self.activation = Numeric.zeros(self.size, 'f')
        self.netinput = Numeric.zeros(self.size, 'f')
        self.targetSet = 0
        self.activationSet = 0
        self.verify = 1
        # layer report of stats:
        self.pcorrect = 0
        self.ptotal = 0
        self.correct = 0
        # misc:
        self.minTarget = 0.0
        self.maxTarget = 1.0
        self.minActivation = 0.0
        self.maxActivation = 1.0
448155
private void calculateKernelMatrix(ExampleSet set, ZipModel model) throws Exception
	{
		// save kernel matrix
		File matrixFile = File.createTempFile("kernel-matrix", null);
		matrixFile.deleteOnExit();

		PrintWriter pw = new PrintWriter(new FileWriter(matrixFile));

		DecimalFormat	decFormatter = new DecimalFormat("0.0");
		logger.info("");
		logger.debug("data set size " + set.size());
		int size = set.size();
		//double[][] matrix = new double[size][size];

		pw.println(size + " " + size);

		for (int i=0;i<size;i++)
		{
			Vector v1 = (Vector) set.x(i);
/*
			for (int j=0;j<i;j++)
			{
				matrix[i][j] = matrix[j][i];
				System.out.print(decFormatter.format(matrix[i][j]) + " ");
			}
	*/
			//for (int j=i;j<size;j++)
			for (int j=0;j<size;j++)
			{
				Vector v2 = (Vector) set.x(j);
				double dot = v1.dotProduct(v2);

				/*
				matrix[i][j] = v1.dotProduct(v2);
				if (matrix[i][j] < 0.3)
					matrix[i][j] = 0;
					*/
				//pw.print(decFormatter.format(matrix[i][j]) + " ");
				pw.print(dot + " ");
			}
			//logger.debug(i + " : " + set.y(i) + "\t" + set.id(i) + "\t" + set.x(i));
			pw.print("\n");
			pw.flush();
		}
		//pw.flush();
		pw.close();

		// add the kernel matrix to the model
		model.add(matrixFile, "kernel-matrix");

/*
		System.out.print("\n");

		//for (int i=0;i<set.size();i++)
		for (int i=0;i<size;i++)
		{
			Vector v1 = (Vector) set.x(i);
			//logger.info(i + " : " + v1);

			for (int j=0;j<i;j++)
				System.out.print(0.0 + " ");

			//for (int j=i;j<set.size();j++)
			for (int j=i;j<size;j++)
			{
				Vector v2 = (Vector) set.x(j);
				double dot = v1.dotProduct(v2);
				System.out.print(decFormatter.format(dot) + " ");
			}
			//logger.debug(i + " : " + set.y(i) + "\t" + set.id(i) + "\t" + set.x(i));
			System.out.print("\n");
		}

		System.out.print("\n");

		System.out.println(size + " " + size);

		//for (int i=0;i<set.size();i++)
		for (int i=0;i<size;i++)
		{
			Vector v1 = (Vector) set.x(i);
			//logger.info(i + " : " + v1);

			//for (int j=i;j<set.size();j++)
			for (int j=i;j<size;j++)
			{
				Vector v2 = (Vector) set.x(j);
				double dot = v1.dotProduct(v2);
				System.out.print(i + " " + j + " ");

				System.out.println(decFormatter.format(dot) + " ");
			}
			//logger.debug(i + " : " + set.y(i) + "\t" + set.id(i) + "\t" + set.x(i));
			System.out.print("\n");
		}
		*/
	}
475319
def initial_guesses(self):
        
        return np.array([param.value for param in self.model.params])
1247657
def _init_runtime(self):
        
        if self.idx != 0:
            from tensorpack.models.registry import disable_layer_logging
            disable_layer_logging()
        self.predictor = OfflinePredictor(self.config)
        if self.idx == 0:
            with self.predictor.graph.as_default():
                describe_trainable_vars()
173933
private void init() {
        dim = mu.length;
        Cholesky cholesky = sigma.cholesky(false);
        sigmaInv = cholesky.inverse();
        sigmaDet = cholesky.det();
        sigmaL = cholesky.getL();
        pdfConstant = (dim * Math.log(2 * Math.PI) + Math.log(sigmaDet)) / 2.0;
    }
1260744
def _initialise_pmf(self):
        """"""
        # Easy vars
        epsilon = self.epsilon
        alpha = self.alpha
        preds = self.predictions
        p1 = self._probs_avg_opt_class
        p0 = 1 - p1
        n_items = self._n_items
        F = self._F_guess

        # Calculate optimal instrumental pmf
        sqrt_arg = np.sum(preds * (alpha**2 * F**2 * p0 + (1 - F)**2 * p1) + \
                          (1 - preds) * (1 - alpha)**2 * F**2 * p1, \
                          axis=1) #: sum is over classifiers
        self._inst_pmf = np.sqrt(sqrt_arg)
        # Normalize
        self._inst_pmf /= np.sum(self._inst_pmf)
        # Epsilon-greedy: (1 - epsilon) q + epsilon * p
        self._inst_pmf *= (1 - epsilon)
        self._inst_pmf += epsilon * 1/n_items
1271123
def init_net_params(scale, layer_sizes, rs=npr.RandomState(0)):
    """"""
    return [(scale * rs.randn(m, n),   # weight matrix
             scale * rs.randn(n))      # bias vector
            for m, n in zip(layer_sizes[:-1], layer_sizes[1:])]
156209
def _init_model(self):
        
        model = Sequential()
        model.add(ConvLSTM2D(filters=self.filters, kernel_size=self.kernel_size, activation=self.activation,
                             input_shape=[self.time_delay] + list(self.image_size) + [self.channels],
                             data_format='channels_last', return_sequences=True))
        model.add(BatchNormalization())
        model.add(ConvLSTM2D(filters=self.filters, kernel_size=self.kernel_size, activation=self.activation,
                             input_shape=(self.time_delay, self.channels) + self.image_size,
                             data_format='channels_last', return_sequences=True))
        model.add(BatchNormalization())
        model.add(ConvLSTM2D(filters=self.filters, kernel_size=self.kernel_size, activation=self.activation))
        model.add(BatchNormalization())
        model.add(Conv2D(filters=1, kernel_size=self.kernel_size, activation="sigmoid", data_format="channels_last"))
        model.add(Flatten())
        model.add(Dense(units=len(self.emotion_map.keys()), activation="sigmoid"))
        if self.verbose:
            model.summary()
        self.model = model
1014780
def _initialize_stretching_matrix(self):
        

        self.S = np.zeros((self.nz, self.nz))

        if (self.nz==2) and (self.rd) and (self.delta):

            self.del1 = self.delta/(self.delta+1.)
            self.del2 = (self.delta+1.)**-1
            self.Us = self.Ubg[0]-self.Ubg[1]

            self.F1 = self.rd**-2 / (1.+self.delta)
            self.F2 = self.delta*self.F1
            self.S[0,0], self.S[0,1] = -self.F1,  self.F1
            self.S[1,0], self.S[1,1] =  self.F2, -self.F2

        else:

            for i in range(self.nz):

                if i == 0:
                    self.S[i,i]   = -self.f2/self.Hi[i]/self.gpi[i]
                    self.S[i,i+1] =  self.f2/self.Hi[i]/self.gpi[i]

                elif i == self.nz-1:
                    self.S[i,i]   = -self.f2/self.Hi[i]/self.gpi[i-1]
                    self.S[i,i-1] =  self.f2/self.Hi[i]/self.gpi[i-1]

                else:
                    self.S[i,i-1] = self.f2/self.Hi[i]/self.gpi[i-1]
                    self.S[i,i]   = -(self.f2/self.Hi[i]/self.gpi[i] +
                                        self.f2/self.Hi[i]/self.gpi[i-1])
                    self.S[i,i+1] = self.f2/self.Hi[i]/self.gpi[i]
710203
private static void initialize()
	{
		for (int i = 0; i < 256; ++i)
		{
			long crc = i;
			for (int j = 8; j > 0; j--)
			{
				if ((crc & 1) == 1)
					crc = (crc >>> 1) ^ polynomial;
				else
					crc >>>= 1;
			}
			values[i] = crc;
		}
		init_done = true;
	}
1350945
def _getHessian(self):
        
        assert self.init,        'GP not initialised'
        assert self.fast==False, 'Not supported for fast implementation'

        if self.cache['Hessian'] is None:
            ParamMask=self.gp.getParamMask()['covar']
            std=sp.zeros(ParamMask.sum())
            H=self.gp.LMLhess_covar()
            It= (ParamMask[:,0]==1)
            self.cache['Hessian']=H[It,:][:,It]

        return self.cache['Hessian']