Package org.apache.mahout.math

Examples of org.apache.mahout.math.Matrix.assign()


      // Row count equals to size of current size and column count equal to size of previous layer
      int row = isFinalLayer ? actualSize : actualSize - 1;
      Matrix weightMatrix = new DenseMatrix(row, sizePrevLayer);
      // Initialize weights
      final RandomWrapper rnd = RandomUtils.getRandom();
      weightMatrix.assign(new DoubleFunction() {
        @Override
        public double apply(double value) {
          return rnd.nextDouble() - 0.5;
        }
      });
View Full Code Here


        examples[i - 1 - batch] = currExample;
        outcomeMatrix[i - 1 - batch] = ArrayUtils.toOutcomeArray(man.readLabel(), 10);
      }
      //Matrix training = new Matrix(examples);
      Matrix training = new DenseMatrix( batchSize, imageExample.length );
      training.assign(examples);
     
      ret.add(new Pair<Matrix, Matrix>(training,MatrixUtils.toMatrix(outcomeMatrix)));
    }

    return ret;
View Full Code Here

        currExample[j] = MathUtils.normalize(currExample[j], 0, 255);
      examples[i - 1] = currExample;
      outcomeMatrix[i - 1] = ArrayUtils.toOutcomeArray(man.readLabel(), 10);
    }
    Matrix training = new DenseMatrix( batchSize, imageExample.length ); //Matrix(examples);
    training.assign(examples);
   
    return new Pair<Matrix,Matrix>(training,MatrixUtils.toMatrix(outcomeMatrix));

  }
View Full Code Here

   
    //MatrixUtils.debug_print(x);
   
   
    Matrix y = new DenseMatrix( n, 2 ); //Matrix.zeros(n,2);
    y.assign(0.0);
   
    for (int i = 0; i < x.numRows(); i++) {
     
      if (x.get(i,0) == x.get(i,1)) {
       
View Full Code Here

   */ 
  public static Matrix columnSums(Matrix m) {

    Matrix ret_col_sums = new DenseMatrix(1, m.numCols());

    ret_col_sums.assign(0.0);

    // sum into 1 row matrix
    for ( int r = 0; r < m.numRows(); r++ ) {
      for ( int c = 0; c < m.numCols(); c++ ) {
        double val = ret_col_sums.get(0, c);
View Full Code Here

    //m.aggregateRows(arg0)
    Matrix ret_col_means = new DenseMatrix(1, m.numCols());
    int row_count = m.numRows();

    ret_col_means.assign(0.0);

    // sum into 1 row matrix
    for ( int r = 0; r < m.numRows(); r++ ) {
      for ( int c = 0; c < m.numCols(); c++ ) {
        double val = ret_col_means.get(0, c);
View Full Code Here

    Matrix ret_row_means = new DenseMatrix(m.numRows(), 1);
    int col_count = m.numCols();

    //System.out.println("col count: " + col_count);;

    ret_row_means.assign(0.0);

    // sum into 1 row matrix
    for ( int r = 0; r < m.numRows(); r++ ) {
      for ( int c = 0; c < m.numCols(); c++ ) {
View Full Code Here

    Matrix ret_row_sums = new DenseMatrix(m.numRows(), 1);
    //int col_count = m.numCols();

    //System.out.println("col count: " + col_count);;

    ret_row_sums.assign(0.0);

    // sum into 1 row matrix
    for ( int r = 0; r < m.numRows(); r++ ) {
      for ( int c = 0; c < m.numCols(); c++ ) {
View Full Code Here

    //    DoubleMatrix ones = DoubleMatrix.ones(x.rows, x.columns);
    //      return ones.div(ones.add(MatrixFunctions.exp(x.neg())));

    Matrix ones = new DenseMatrix(m.numRows(), m.numCols());
    ones.assign(1.0);


    Matrix m1 = MatrixUtils.neg( m );

View Full Code Here

   * @return
   */
  public static Matrix ones(int rows, int cols) {

    Matrix ret = new DenseMatrix(rows, cols);
    ret.assign(1.0);

    return ret;
  }
 
  public static Matrix uniform(RandomGenerator rng, int rows, int cols) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.