Package org.apache.mahout.math

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


        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 void testEnsureValidOutcomeMatrix() {
   
    boolean caughtBad = false;
   
    Matrix bad = new DenseMatrix(2, 3);
    bad.assign(0.0);
   
    try {
      MatrixUtils.ensureValidOutcomeMatrix(bad);
    } catch (Exception e) {
      caughtBad = true;
View Full Code Here

    }
   
    assertEquals( true, caughtBad );
   
    Matrix good = new DenseMatrix(2, 3);
    good.assign(0.0);
    good.set(0, 1, 2.0);
   
    boolean caughtGood = false;
   
    try {
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.