Package org.encog.ml.data

Examples of org.encog.ml.data.MLDataPair


    BasicMLData ideal = new BasicMLData(1);
    ImageNeuralData input = new ImageNeuralData(image);
    set.add(input,ideal);
    set.downsample(2,2);
    Iterator<MLDataPair> itr = set.iterator();
    MLDataPair pair = (MLDataPair)itr.next();
    MLData data = pair.getInput();
    double[] d = data.getData();
    //Assert.assertEquals(d[0],-1.0, 0.1);
    //Assert.assertEquals(d[5],1, 0.1);
   
    // just "flex" these for no exceptions
View Full Code Here


      MLDataSet result = new BasicMLDataSet();
      for(int i=0;i<count;i++) {
        for(int j=0;j<4;j++) {
          MLData inputData = new BasicMLData(XOR_INPUT[j]);
          MLData idealData = new BasicMLData(XOR_IDEAL[j]);
          MLDataPair pair = new BasicMLDataPair(inputData,idealData);
          inputData.setData(0, inputData.getData(0)+RangeRandomizer.randomize(-0.1, 0.1));
          inputData.setData(1, inputData.getData(1)+RangeRandomizer.randomize(-0.1, 0.1));
          result.add(pair);
        }
      }
View Full Code Here

   *            The size of the ideal data.
   * @return A new data pair object.
   */
  public static MLDataPair createPair(final int inputSize,
      final int idealSize) {
    MLDataPair result;

    if (idealSize > 0) {
      result = new BasicMLDataPair(new BasicMLData(inputSize),
          new BasicMLData(idealSize));
    } else {
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  public final void add(final MLData inputData, final MLData idealData) {

    final MLDataPair pair = new BasicMLDataPair(inputData, idealData);
    this.data.add(pair);
  }
View Full Code Here

  @Override
  public final int getIdealSize() {
    if (this.data.isEmpty()) {
      return 0;
    }
    final MLDataPair first = this.data.get(0);
    if (first.getIdeal() == null) {
      return 0;
    }

    return first.getIdeal().size();
  }
View Full Code Here

  @Override
  public final int getInputSize() {
    if (this.data.isEmpty()) {
      return 0;
    }
    final MLDataPair first = this.data.get(0);
    return first.getInput().size();
  }
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  public final void getRecord(final long index, final MLDataPair pair) {

    final MLDataPair source = this.data.get((int) index);
    pair.setInputArray(source.getInputArray());
    if (pair.getIdealArray() != null) {
      pair.setIdealArray(source.getIdealArray());
    }

  }
View Full Code Here

  public void refresh() {
    int selected = this.list.getSelectedIndex();
    if( selected==-1 )
      return;
   
    MLDataPair pair = BasicMLDataPair.createPair(this.data.getInputSize(), this.data.getIdealSize());
    this.data.getRecord(selected, pair);
    int gridHeight;
    int gridWidth;
   
    try {
      gridHeight = Integer.parseInt(this.fieldHeight.getText());
      if( gridHeight<=0 )
        throw new NumberFormatException();
    } catch(NumberFormatException ex) {
      EncogWorkBench.displayError("Error", "Invalid height.");
      return;
    }
   
    try {
      gridWidth = Integer.parseInt(this.fieldWidth.getText());
      if( gridHeight<=0 )
        throw new NumberFormatException();
    } catch(NumberFormatException ex) {
      EncogWorkBench.displayError("Error", "Invalid width.");
      return;
    }
   
    this.grid.updateData(gridHeight,gridWidth,pair.getInput().getData());
  }
View Full Code Here

      int input = dialog.getInput().getValue();
      int output = dialog.getIdeal().getValue();

      BufferedNeuralDataSet trainingData = new BufferedNeuralDataSet(file);

      MLDataPair pair = BasicMLDataPair.createPair(input,
          output);
      trainingData.beginLoad(input, output);
      for (int i = 0; i < elements; i++) {
        trainingData.add(pair);
      }
View Full Code Here

    } else if (field instanceof InputFieldMLDataSet) {
      final InputFieldMLDataSet neuralField =
        (InputFieldMLDataSet) field;
      final MLDataFieldHolder holder = this.dataSetFieldMap
          .get(field);
      final MLDataPair pair = holder.getPair();
      int offset = neuralField.getOffset();
      if (offset < pair.getInput().size()) {
        result = pair.getInput().getData(offset);
      } else {
        offset -= pair.getInput().size();
        result = pair.getIdeal().getData(offset);
      }
    } else {
      result = field.getValue(index);
    }
View Full Code Here

TOP

Related Classes of org.encog.ml.data.MLDataPair

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.