Package org.apache.mahout.math

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


    DenseVector activations = new DenseVector(numHidden);
    for (int i = 0; i < numHidden; i++) {
      activations.setQuick(i, hiddenWeights[i].dot(input));
    }
    activations.assign(hiddenBias, Functions.PLUS);
    activations.assign(Functions.min(40.0)).assign(Functions.max(-40));
    activations.assign(Functions.SIGMOID);
    return activations;
  }

  /**
 
View Full Code Here


    for (int i = 0; i < numHidden; i++) {
      activations.setQuick(i, hiddenWeights[i].dot(input));
    }
    activations.assign(hiddenBias, Functions.PLUS);
    activations.assign(Functions.min(40.0)).assign(Functions.max(-40));
    activations.assign(Functions.SIGMOID);
    return activations;
  }

  /**
   * Feeds forward from hidden to output
View Full Code Here

  public DenseVector hiddenToOutput(Vector hiddenActivation) {
    DenseVector activations = new DenseVector(numOutput);
    for (int i = 0; i < numOutput; i++) {
      activations.setQuick(i, outputWeights[i].dot(hiddenActivation));
    }
    activations.assign(outputBias, Functions.PLUS);
    return activations;
  }

  /**
   * Updates using ranking loss.
View Full Code Here

    Preconditions.checkArgument(userRatings.isSequentialAccess(), "need sequential access to ratings!");

    Vector YtransponseCuPu = new DenseVector(numFeatures);

    for (Element e : userRatings.nonZeroes()) {
      YtransponseCuPu.assign(Y.get(e.index()).times(confidence(e.get())), Functions.PLUS);
    }

    return columnVectorAsMatrix(YtransponseCuPu);
  }
View Full Code Here

   * For the distributed case, the best guess at a useful initialization state for Lanczos we'll chose to be
   * uniform over all input dimensions, L_2 normalized.
   */
  public static Vector getInitialVector(VectorIterable corpus) {
    Vector initialVector = new DenseVector(corpus.numCols());
    initialVector.assign(1.0 / Math.sqrt(corpus.numCols()));
    return initialVector;
  }

  public LanczosState runJob(Configuration originalConfig,
                             LanczosState state,
View Full Code Here

   *          initial classification bias.
   */
  protected LinearTrainer(int dimension, double threshold,
                          double init, double initBias) {
    DenseVector initialWeights = new DenseVector(dimension);
    initialWeights.assign(init);
    this.model = new LinearModel(initialWeights, initBias, threshold);
  }
 
  /**
   * Initializes training. Runs through all data points in the training set and
View Full Code Here

  public static List<Vector> generateVectorBasis(int projectedVectorSize, int vectorSize) {
    DoubleFunction random = new Normal();
    List<Vector> basisVectors = Lists.newArrayList();
    for (int i = 0; i < projectedVectorSize; ++i) {
      Vector basisVector = new DenseVector(vectorSize);
      basisVector.assign(random);
      basisVector.normalize();
      basisVectors.add(basisVector);
    }
    return basisVectors;
  }
View Full Code Here

        dv.setQuick(rnd.nextInt(n), muAmplitude * (rnd.nextDouble() - 0.25));
      }
      roww.set(i);
      vw.set(dv);
      w.append(roww, vw);
      xi.assign(dv, Functions.PLUS);
    }
    closeables.remove(w);
    Closeables.close(w, false);

    // TODO fix test so that 1.0/m works as intended!
View Full Code Here

    }
    closeables.remove(w);
    Closeables.close(w, false);

    // TODO fix test so that 1.0/m works as intended!
    xi.assign(Functions.mult(1 / m));

    FileSystem fs = FileSystem.get(conf);

    Path tempDirPath = getTestTempDirPath("svd-proc");
    Path aPath = new Path(tempDirPath, "A/A.seq");
View Full Code Here

     
      double alpha = conditionedNormSqr / updateDirection.dot(aTimesUpdate);
     
      // x = x + alpha * updateDirection
      PLUS_MULT.setMultiplicator(alpha);
      x.assign(updateDirection, PLUS_MULT);

      // residual = residual - alpha * A * updateDirection
      PLUS_MULT.setMultiplicator(-alpha);
      residual.assign(aTimesUpdate, PLUS_MULT);
     
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.