/** * Gets the number of hidden units, not including the bias term. * @return * Number of hidden units, must be greater than zero. */ public int getHiddenDimensionality() { return this.hiddenToOutputWeights.getNumColumns(); }
/** * Gets the number of hidden units, not including the bias term. * @return * Number of hidden units, must be greater than zero. */ public int getHiddenDimensionality() { return this.hiddenToOutputWeights.getNumColumns(); }
@Override public int getInputDimensionality() { return this.getDiscriminant().getNumColumns(); }
private Matrix repmat(Matrix dL1, int nRows, int nCols) { final Matrix out = DMF.createMatrix(nRows * dL1.getNumRows(), nCols * dL1.getNumColumns()); for (int i = 0; i < nRows; i++) { for (int j = 0; j < nCols; j++) { out.setSubMatrix(i * dL1.getNumRows(), j * dL1.getNumColumns(), dL1); } } return out; }
/** * Returns the expected dimension of input Vectors * @return * Expected dimension of input Vectors */ public int getInputDimensionality() { return this.getDimensionReducer().getDiscriminant().getNumColumns(); }
private Matrix repmat(Matrix dL1, int nRows, int nCols) { final Matrix out = DMF.createMatrix(nRows * dL1.getNumRows(), nCols * dL1.getNumColumns()); for (int i = 0; i < nRows; i++) { for (int j = 0; j < nCols; j++) { out.setSubMatrix(i * dL1.getNumRows(), j * dL1.getNumColumns(), dL1); } } return out; }
/** * Returns the expected dimension of input Vectors * @return * Expected dimension of input Vectors */ public int getInputDimensionality() { return this.getDimensionReducer().getDiscriminant().getNumColumns(); }
/** * @param vt * @return mean of each row */ public static Vector rowMean(Matrix vt) { final Vector sumOfColumns = vt.sumOfColumns(); sumOfColumns.scaleEquals(1. / vt.getNumColumns()); return sumOfColumns; }
/** * Expand the U parameters matrix by added a set of rows. * If currently unset, this function does nothing (assuming U will be initialised in the first round) * The new U parameters are initialised used {@link BilinearLearnerParameters#EXPANDEDUINITSTRAT} * @param newUsers the number of new users to add */ public void addU(int newUsers) { if(this.u == null) return; // If u has not be inited, then it will be on first process final InitStrategy ustrat = this.getInitStrat(BilinearLearnerParameters.EXPANDEDUINITSTRAT,null,null); final Matrix newU = ustrat.init(newUsers, this.u.getNumColumns()); this.u = CFMatrixUtils.vstack(this.u,newU); }
@Override public boolean checkSameDimensions( Matrix otherMatrix ) { return (this.getNumRows() == otherMatrix.getNumRows()) && (this.getNumColumns() == otherMatrix.getNumColumns()); }
@Override public boolean checkSameDimensions( Matrix otherMatrix ) { return (this.getNumRows() == otherMatrix.getNumRows()) && (this.getNumColumns() == otherMatrix.getNumColumns()); }
private static double[][] fromMatrix(Matrix a) { final double[][] ret = new double[a.getNumRows()][a.getNumColumns()]; for (final MatrixEntry ds : a) { ret[ds.getRowIndex()][ds.getColumnIndex()] = ds.getValue(); } return ret; }
@Override public Matrix apply(Matrix in) { final Matrix out = DMF.copyMatrix(in); for (int i = 0; i < in.getNumRows(); i++) { for (int j = 0; j < in.getNumColumns(); j++) { out.setElement(i, j, g.apply(in.getElement(i, j))); } } return out; }
@Override public Matrix apply(Matrix in) { final Matrix out = DMF.copyMatrix(in); for (int i = 0; i < in.getNumRows(); i++) { for (int j = 0; j < in.getNumColumns(); j++) { out.setElement(i, j, gPrime.apply(in.getElement(i, j))); } } return out; }
@Override public Matrix apply(Matrix in) { final Matrix out = DMF.copyMatrix(in); for (int i = 0; i < in.getNumRows(); i++) { for (int j = 0; j < in.getNumColumns(); j++) { out.setElement(i, j, g.apply(in.getElement(i, j))); } } return out; }
@Override public void assertSameDimensions( Matrix other ) { if (!this.checkSameDimensions(other)) { throw new DimensionalityMismatchException( "Matrices must have same dimensions: " + "(" + this.getNumRows() + "x" + this.getNumColumns() + ") !=" + "(" + other.getNumRows() + "x" + other.getNumColumns() + ")" ); } }
@Override public Matrix apply(Matrix in) { final Matrix out = DMF.copyMatrix(in); for (int i = 0; i < in.getNumRows(); i++) { for (int j = 0; j < in.getNumColumns(); j++) { out.setElement(i, j, gPrime.apply(in.getElement(i, j))); } } return out; }
/** * @param laplacian * @return copy and convert */ public static Jama.Matrix asJama(Matrix laplacian) { final Jama.Matrix ret = new Jama.Matrix(laplacian.getNumRows(), laplacian.getNumColumns()); for (final MatrixEntry matrixEntry : laplacian) { ret.set(matrixEntry.getRowIndex(), matrixEntry.getColumnIndex(), matrixEntry.getValue()); } return ret; }
/** * Creates a new instance of MultivariateGaussianMeanBayesianEstimator * @param knownCovarianceInverse * Known covariance matrix of the estimated mean. */ public MultivariateGaussianMeanBayesianEstimator( Matrix knownCovarianceInverse ) { this( knownCovarianceInverse, new MultivariateGaussian( VectorFactory.getDefault().createVector(knownCovarianceInverse.getNumRows()), MatrixFactory.getDefault().createIdentity(knownCovarianceInverse.getNumRows(), knownCovarianceInverse.getNumColumns()) ) ); }
/** * Creates a new instance of MultivariateGaussianMeanBayesianEstimator * @param knownCovarianceInverse * Known covariance matrix of the estimated mean. */ public MultivariateGaussianMeanBayesianEstimator( Matrix knownCovarianceInverse ) { this( knownCovarianceInverse, new MultivariateGaussian( VectorFactory.getDefault().createVector(knownCovarianceInverse.getNumRows()), MatrixFactory.getDefault().createIdentity(knownCovarianceInverse.getNumRows(), knownCovarianceInverse.getNumColumns()) ) ); }