Examples of MLData


Examples of org.encog.ml.data.MLData

    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);

      // display
      System.out.println((STARTING_YEAR + year) + "\t"
          + f.format(this.normalizedSunspots[year]) + "\t"
          + f.format(prediction) + "\t"
View Full Code Here

Examples of org.encog.ml.data.MLData

  }
 
  public int autonomousMoveDirection()
  {
    updateVision();
    MLData result = this.brain.compute(this.vision);
   
    double winningOutput = Double.NEGATIVE_INFINITY;
    int winningDirection = 0;
   
    for(int i=0;i<result.size();i++)
    {
      // determine direction
      int direction = directionFromIndex(i);     
     
      if( this.environment.isWall(this.x, this.y, direction))
        continue;
     
      // evaluate if this is a "winning" direction
      double thisOutput = result.getData(i);
      if( thisOutput>winningOutput)
      {
        winningOutput = thisOutput;
        winningDirection = direction;
      }
View Full Code Here

Examples of org.encog.ml.data.MLData

    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

Examples of org.encog.ml.data.MLData

   
    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

Examples of org.encog.ml.data.MLData

    int currentRecord = 0;
    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);
View Full Code Here

Examples of org.encog.ml.data.MLData

  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

Examples of org.encog.ml.data.MLData

    } while(train.getError() > 0.01);

    // test the neural network
    System.out.println("Neural Network Results:");
    for(MLDataPair pair: trainingSet ) {
      final MLData output = network.compute(pair.getInput());
      System.out.println(pair.getInput().getData(0) + "," + pair.getInput().getData(1)
          + ", actual=" + output.getData(0) + ",ideal=" + pair.getIdeal().getData(0));
    }
  }
View Full Code Here

Examples of org.encog.ml.data.MLData

    {
      train.iteration();
      System.out.println("Iteration: " + iteration + ", Error:" + train.getError());
    }
   
    MLData data1 = new BasicMLData(SOM_INPUT[0]);
    MLData data2 = new BasicMLData(SOM_INPUT[1]);
    System.out.println("Pattern 1 winner: " + network.winner(data1));
    System.out.println("Pattern 2 winner: " + network.winner(data2));
  }
View Full Code Here

Examples of org.encog.ml.data.MLData

    for (int i = 0; i < map.length; i++) {
      map[i] = '?';
    }
    for (int i = 0; i < this.letterListModel.size(); i++) {
      final MLData input = new BasicMLData(5 * 7);
      int idx = 0;
      final SampleData ds = (SampleData) this.letterListModel
          .getElementAt(i);
      for (int y = 0; y < ds.getHeight(); y++) {
        for (int x = 0; x < ds.getWidth(); x++) {
          input.setData(idx++, ds.getData(x, y) ? .5 : -.5);
        }
      }

      final int best = this.net.winner(input);
      map[best] = ds.getLetter();
View Full Code Here

Examples of org.encog.ml.data.MLData

          "Error", JOptionPane.ERROR_MESSAGE);
      return;
    }
    this.entry.downSample();

    final MLData input = new BasicMLData(5 * 7);
    int idx = 0;
    final SampleData ds = this.sample.getData();
    for (int y = 0; y < ds.getHeight(); y++) {
      for (int x = 0; x < ds.getWidth(); x++) {
        input.setData(idx++, ds.getData(x, y) ? .5 : -.5);
      }
    }

    final int best = this.net.winner(input);
    final char map[] = mapNeurons();
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.