Package org.encog.ml.data.basic

Examples of org.encog.ml.data.basic.BasicMLData


    return Math.sin(rad);
  }
 
  public double obtainPrediction(int angle)
  {
    MLData input = new BasicMLData(PredictSIN.INPUT_WINDOW);
    if( angle< PredictSIN.INPUT_WINDOW )
      return this.predict[angle];
   
    int index = angle - PredictSIN.INPUT_WINDOW;
    for(int i=0;i<PredictSIN.INPUT_WINDOW;i++)
    {
      input.setData(i,this.actual[index++]);
    }
   
    MLData output = this.network.compute(input);
    return output.getData(0);
   
View Full Code Here


  public static MLDataSet generateTraining()
  {
    MLDataSet result = new BasicMLDataSet();
    for(int i=0;i<DIGITS.length;i++)
    {     
      BasicMLData ideal = new BasicMLData(DIGITS.length);
     
      // setup input
      MLData input = image2data(DIGITS[i]);
     
      // setup ideal
      for(int j=0;j<DIGITS.length;j++)
      {
        if( j==i )
          ideal.setData(j,1);
        else
          ideal.setData(j,-1);
      }
     
      // add training element
      result.add(input,ideal);
    }
View Full Code Here

    return result;
  }
 
  public static MLData image2data(String[] image)
  {
    MLData result = new BasicMLData(CHAR_WIDTH*CHAR_HEIGHT);
   
    for(int row = 0; row<CHAR_HEIGHT; row++)
    {
      for(int col = 0; col<CHAR_WIDTH; col++)
      {
        int index = (row*CHAR_WIDTH) + col;
        char ch = image[row].charAt(col);
        result.setData(index,ch=='O'?1:-1 );
      }
    }
   
    return result;
  }
View Full Code Here

    while (csv.next()) {
      MLData input = null;
      MLData ideal = null;
      int index = 0;

      input = new BasicMLData(inputSize);
      for (int i = 0; i < inputSize; i++) {
        double d = csv.getDouble(index++);
        input.setData(i, d);
      }

      if (idealSize > 0) {
        ideal = new BasicMLData(idealSize);
        for (int i = 0; i < idealSize; i++) {
          double d = csv.getDouble(index++);
          ideal.setData(i, d);
        }
      }
View Full Code Here

    System.out.println("Year\tActual\tPredict\tClosed Loop Predict");

    for (int year = EVALUATE_START; year < EVALUATE_END; year++) {
      // calculate based on actual data
      MLData input = new BasicMLData(WINDOW_SIZE);
      for (int i = 0; i < input.size(); i++) {
        input.setData(i, this.normalizedSunspots[(year - WINDOW_SIZE)
            + i]);
      }
      MLData output = network.compute(input);
      double prediction = output.getData(0);
      this.closedLoopSunspots[year] = prediction;

      // calculate "closed loop", based on predicted data
      for (int i = 0; i < input.size(); i++) {
        input.setData(i, this.closedLoopSunspots[(year - WINDOW_SIZE)
            + i]);
      }
      output = network.compute(input);
      double closedLoopPrediction = output.getData(0);
View Full Code Here

  public NeuralMouse(BasicNetwork brain, Maze environment) {
    this.brain = brain;
    this.environment = environment;
    this.x = 0;
    this.y = 0;
    this.vision = new BasicMLData(Constants.VISION_POINTS);
  }
View Full Code Here

    LinearCongruentialGenerator rand =
      new LinearCongruentialGenerator(seed);
   
    final BasicMLDataSet result = new BasicMLDataSet();
    for (int i = 0; i < count; i++) {
      final MLData inputData = new BasicMLData(inputCount);

      for (int j = 0; j < inputCount; j++) {
        inputData.setData(j, rand.range(min, max));
      }

      final MLData idealData = new BasicMLData(idealCount);

      for (int j = 0; j < idealCount; j++) {
        idealData.setData(j, rand.range(min, max));
      }

      final BasicMLDataPair pair = new BasicMLDataPair(inputData,
          idealData);
      result.add(pair);
View Full Code Here

   
    int inputCount = training.getInputSize();
    int idealCount = training.getIdealSize();
   
    for (int i = 0; i < count; i++) {
      final MLData inputData = new BasicMLData(inputCount);

      for (int j = 0; j < inputCount; j++) {
        inputData.setData(j, rand.range(min, max));
      }

      final MLData idealData = new BasicMLData(idealCount);

      for (int j = 0; j < idealCount; j++) {
        idealData.setData(j, rand.range(min, max));
      }

      final BasicMLDataPair pair = new BasicMLDataPair(inputData,
          idealData);
      training.add(pair);
View Full Code Here

    int lastUpdate = 0;

    while (this.codec.read(input, ideal, significance)) {
      MLData a = null, b = null;

      a = new BasicMLData(input);

      if (this.codec.getIdealSize() > 0) {
        b = new BasicMLData(ideal);
      }

      final MLDataPair pair = new BasicMLDataPair(a, b);
      pair.setSignificance(significance[0]);
      this.result.add(pair);
View Full Code Here

  private void processNetwork() throws IOException {
    System.out.println("Downsampling images...");

    for (final ImagePair pair : this.imageList) {
      final MLData ideal = new BasicMLData(this.outputCount);
      final int idx = pair.getIdentity();
      for (int i = 0; i < this.outputCount; i++) {
        if (i == idx) {
          ideal.setData(i, 1);
        } else {
          ideal.setData(i, -1);
        }
      }

      final Image img = ImageIO.read(pair.getFile());
      final ImageNeuralData data = new ImageNeuralData(img);
View Full Code Here

TOP

Related Classes of org.encog.ml.data.basic.BasicMLData

Copyright © 2018 www.massapicom. 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.