Package org.apache.mahout.math

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


    assertEquals(0, a.viewPart(0, 3, 1, 3).viewDiagonal().minus(
        new DenseVector(new double[]{2, 6, 9})).norm(1), 1.0e-10);
    assertEquals(4, a.get(0, 3), 1.0e-10);
    print(a);
    Matrix m = new DenseMatrix(4, 4).assign(a);
    assertEquals(0, m.minus(a).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
    print(m);

    assertEquals(0, m.transpose().times(m).minus(a.transpose().times(a)).aggregate(
        Functions.PLUS, Functions.ABS), 1.0e-10);
    assertEquals(0, m.plus(m).minus(a.plus(a)).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
View Full Code Here


    @Override
    public double squaredLoss() {
        Matrix reconstructed = reconstruct( this.trainingDataset );

        //double loss = MatrixFunctions.powi(reconstructed.sub(input), 2).sum() / input.rows;
        double loss = MatrixUtils.sum( MatrixUtils.pow( reconstructed.minus( this.trainingDataset ), 2 ) ) / this.trainingDataset.numRows();

        if(this.useRegularization) {
            //loss += 0.5 * l2 * MatrixFunctions.pow(W,2).sum();
            loss += 0.5 * l2 * MatrixUtils.sum( MatrixUtils.pow( this.connectionWeights, 2 ) );
        }
View Full Code Here

     
      //System.out.println("regularization! " + l2);
     
      // TODO: figure out if this should stick around like this
      this.connectionWeights = this.connectionWeights.times(l2);
      wGradient = wGradient.minus(this.connectionWeights);
   
    }

   
    if (momentum != 0) {
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.