Package org.apache.mahout.math

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


      // 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


          bTmp.readFields(in);
        } finally {
          in.close();
        }

        b2.assign(bTmp.get().times(bTmp.get().transpose()), Functions.PLUS);
      }
    }
    l2 = new CholeskyDecomposition(b2);
    svd = new SingularValueDecomposition(l2.getL());
  }
View Full Code Here

      if (pcaMeanPath != null) {
        Vector sq = SSVDHelper.loadAndSumUpVectors(sqPath, conf);
        Vector sb = SSVDHelper.loadAndSumUpVectors(sbPath, conf);
        Matrix mC = sq.cross(sb);

        bbtSquare.assign(mC, Functions.MINUS);
        bbtSquare.assign(mC.transpose(), Functions.MINUS);
        mC = null;

        Matrix outerSq = sq.cross(sq);
        outerSq.assign(Functions.mult(xisquaredlen));
View Full Code Here

        Vector sq = SSVDHelper.loadAndSumUpVectors(sqPath, conf);
        Vector sb = SSVDHelper.loadAndSumUpVectors(sbPath, conf);
        Matrix mC = sq.cross(sb);

        bbtSquare.assign(mC, Functions.MINUS);
        bbtSquare.assign(mC.transpose(), Functions.MINUS);
        mC = null;

        Matrix outerSq = sq.cross(sq);
        outerSq.assign(Functions.mult(xisquaredlen));
        bbtSquare.assign(outerSq, Functions.PLUS);
View Full Code Here

        bbtSquare.assign(mC.transpose(), Functions.MINUS);
        mC = null;

        Matrix outerSq = sq.cross(sq);
        outerSq.assign(Functions.mult(xisquaredlen));
        bbtSquare.assign(outerSq, Functions.PLUS);

      }

      EigenSolverWrapper eigenWrapper = new EigenSolverWrapper(SSVDHelper.extractRawData(bbtSquare));
      Matrix uHat = new DenseMatrix(eigenWrapper.getUHat());
View Full Code Here

   *
   * @return D
   */
  public Matrix getD() {
    Matrix x = new DenseMatrix(n, n);
    x.assign(0);
    x.viewDiagonal().assign(d);
    for (int i = 0; i < n; i++) {
      final double v = e.getQuick(i);
      if (v > 0) {
        x.setQuick(i, i + 1, v);
View Full Code Here

    DenseMatrix transitionMatrix = new DenseMatrix(nrOfHiddenStates, nrOfHiddenStates);
    DenseMatrix emissionMatrix = new DenseMatrix(nrOfHiddenStates, nrOfOutputStates);
    // assign a small initial probability that is larger than zero, so
    // unseen states will not get a zero probability
    transitionMatrix.assign(pseudoCount);
    emissionMatrix.assign(pseudoCount);
    // given no prior knowledge, we have to assume that all initial hidden
    // states are equally likely
    DenseVector initialProbabilities = new DenseVector(nrOfHiddenStates);
    initialProbabilities.assign(1.0 / (double) nrOfHiddenStates);
View Full Code Here

        nrOfOutputStates);
    DenseVector initialProbabilities = new DenseVector(nrOfHiddenStates);

    // assign pseudo count to avoid zero probabilities
    transitionMatrix.assign(pseudoCount);
    emissionMatrix.assign(pseudoCount);
    initialProbabilities.assign(pseudoCount);

    // now loop over the sequences to count the number of transitions
    Iterator<int[]> hiddenSequenceIt = hiddenSequences.iterator();
    Iterator<int[]> observedSequenceIt = observedSequences.iterator();
View Full Code Here

      // 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

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.