Package de.jungblut.math

Examples of de.jungblut.math.DoubleVector.divide()


      // return null so minimizers should fast-fail
      return null;
    }
    // just return an average over the batches
    return new CostGradientTuple(costSum / submittedBatches,
        gradientSum.divide(submittedBatches));
  }

  /**
   * Evaluate the batch.
   *
 
View Full Code Here


        break;
      case AVERAGE:
        for (int i = 0; i < result.length; i++) {
          toReturn = toReturn.add(result[i]);
        }
        toReturn = toReturn.divide(classifier.length);
        break;
      default:
        throw new UnsupportedOperationException("Type " + type
            + " isn't supported yet!");
    }
View Full Code Here

  }

  @Override
  public DoubleVector predictProbability(DoubleVector features) {
    DoubleVector predict = predict(features);
    return predict.divide(predict.sum());
  }

  @Override
  public int extractPredictedClass(DoubleVector predict) {
    if (predict.getLength() == 1) {
View Full Code Here

        newCenter = value.getVector().deepCopy();
      else
        newCenter = newCenter.add(value.getVector());
    }

    newCenter = newCenter.divide(vectorList.size());
    ClusterCenter center = new ClusterCenter(newCenter);
    centers.add(center);
    for (VectorWritable vector : vectorList) {
      context.write(center, vector);
    }
View Full Code Here

    for (int row = 0; row < transitionProbabilityMatrix.getRowCount(); row++) {
      // note that we are using row vectors here, because dense matrices give us
      // the underlying array wrapped by the vector object so we can directly
      // mutate the values beneath
      DoubleVector rowVector = transitionProbabilityMatrix.getRowVector(row);
      rowVector = rowVector.divide(rowVector.sum());
      if (log) {
        rowVector = rowVector.log();
      }
      transitionProbabilityMatrix.setRowVector(row, rowVector);
      rowVector = emissionProbabilitiyMatrix.getRowVector(row);
View Full Code Here

      if (log) {
        rowVector = rowVector.log();
      }
      transitionProbabilityMatrix.setRowVector(row, rowVector);
      rowVector = emissionProbabilitiyMatrix.getRowVector(row);
      rowVector = rowVector.divide(rowVector.sum());
      if (log) {
        rowVector = rowVector.log();
      }
      emissionProbabilitiyMatrix.setRowVector(row, rowVector);
    }
View Full Code Here

  @Override
  public DoubleVector predictProbability(DoubleVector features) {
    DoubleVector prediction = predict(features);
    if (numOutcomes != 2) {
      prediction = prediction.divide(prediction.sum());
    }
    return prediction;
  }

  /**
 
View Full Code Here

    } else {
      for (int i = 0; i < subtract.getLength(); i++) {
        subtract.set(i, Math.exp(subtract.get(i)));
      }
    }
    return subtract.divide(subtract.sum());
  }

  @Override
  public DoubleMatrix apply(DoubleMatrix matrix) {
    DoubleMatrix dm = newInstance(matrix);
View Full Code Here

    for (int state = 0; state < probabilities.getDimension(); state++) {
      probabilities.set(state, FastMath.exp(probabilities.get(state) - max)
          * hiddenPriorProbability.get(state));
    }
    // normalize again
    return probabilities.divide(probabilities.sum());
  }

  public DoubleVector predict(DoubleVector features,
      DoubleVector previousOutcome) {
    // clamp the features to the visible units, calculate the joint
View Full Code Here

    for (int state = 0; state < probabilities.getDimension(); state++) {
      probabilities.set(state, FastMath.exp(probabilities.get(state) - max)
          * hiddenPriorProbability.get(state));
    }
    // normalize again
    return probabilities.divide(probabilities.sum());
  }

  public int getNumHiddenStates() {
    return this.numHiddenStates;
  }
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.