Package org.encog.ml.data.basic

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


   *            The input to this synapse.
   * @return The output from this synapse.
   */
  @Override
  public MLData compute(final MLData input) {
    final MLData result = new BasicMLData(this.outputCount);

    // clear from previous
    EngineArray.fill(this.preActivation, 0.0);
    EngineArray.fill(this.postActivation, 0.0);
    this.postActivation[0] = 1.0;

    // copy input
    EngineArray.arrayCopy(input.getData(), 0, this.postActivation, 1,
        this.inputCount);

    // iterate through the network activationCycles times
    for (int i = 0; i < this.activationCycles; ++i) {
      internalCompute();
    }

    // copy output
    EngineArray.arrayCopy(this.postActivation, this.outputIndex,
        result.getData(), 0, this.outputCount);

    return result;
  }
View Full Code Here


    }
   
    int inputCount = analyst.getScript().getNormalize().calculateInputColumns();
    int idealCount = analyst.getScript().getNormalize().calculateOutputColumns();
   
        BasicMLData inputData = new BasicMLData(inputCount);
        BasicMLData idealData = new BasicMLData(idealCount);

    ReadCSV csv = null;
    BufferedMLDataSet buffer = new BufferedMLDataSet(file);
    buffer.beginLoad(inputCount,idealCount);

    try {
      csv = new ReadCSV(getInputFilename().toString(),
          isExpectInputHeaders(), getFormat());

      resetStatus();
      final int outputLength = this.analyst.determineTotalColumns();

      // write file contents
      while (csv.next() && !shouldStop()) {
        updateStatus(false);

        double[] output = AnalystNormalizeCSV.extractFields(
            this.analyst, this.analystHeaders, csv, outputLength,
            false);

        if (this.series.getTotalDepth() > 1) {
          output = this.series.process(output);
        }
       
        // copy the input
        int idx = 0;
        for(int i=0;i<inputData.size();i++) {
          inputData.setData(i, output[idx++]);
        }
       
        for(int i=0;i<idealData.size();i++) {
          idealData.setData(i, output[idx++]);
        }

        if (output != null) {
          buffer.add(inputData,idealData);
        }
View Full Code Here

      for (int i = 0; i < getOutputCount(); i++) {
        out[i] /= psum;
      }
    }

    return new BasicMLData(out);
  }
View Full Code Here

          && section.getSubSectionName().equals("SAMPLES")) {
        for (final String line : section.getLines()) {
          final List<String> cols = EncogFileSection
              .splitColumns(line);
          int index = 0;
          final MLData inputData = new BasicMLData(inputCount);
          for (int i = 0; i < inputCount; i++) {
            inputData.setData(i,
                CSVFormat.EG_FORMAT.parse(cols.get(index++)));
          }
          final MLData idealData = new BasicMLData(outputCount);
          idealData.setData(0,CSVFormat.EG_FORMAT.parse(cols.get(index++)));
          final MLDataPair pair = new BasicMLDataPair(inputData,idealData);
          samples.add(pair);
        }
      }
    }
View Full Code Here

   *            The input pattern.
   * @return The output activation of each output neuron.
   */
  private MLData compute(final SOM som, final MLData input) {

    final MLData result = new BasicMLData(som.getOutputCount());

    for (int i = 0; i < som.getOutputCount(); i++) {
      final Matrix optr = som.getWeights().getRow(i);
      final Matrix inputMatrix = Matrix.createRowMatrix(input.getData());
      result.setData(i, MatrixMath.dotProduct(inputMatrix, optr));
    }

    return result;
  }
View Full Code Here

   *            The input.
   * @param output
   *            The output.
   */
  public void compute(final double[] input, final double[] output) {
    final BasicMLData input2 = new BasicMLData(input);
    final MLData output2 = this.compute(input2);
    EngineArray.arrayCopy(output2.getData(), output);
  }
View Full Code Here

   * @return The output from the neural network.
   */
  @Override
  public MLData compute(final MLData input) {
    try {
      final MLData result = new BasicMLData(this.structure.getFlat()
          .getOutputCount());
      this.structure.getFlat().compute(input.getData(), result.getData());
      return result;
    } catch (final ArrayIndexOutOfBoundsException ex) {
      throw new NeuralNetworkError(
          "Index exception: there was likely a mismatch between layer sizes, or the size of the input presented to the network.",
          ex);
View Full Code Here

   
    ImageMLData inputImage1 = new ImageMLData(ImageIO.read(IMG_A));
    ImageMLData inputImage2 = new ImageMLData(ImageIO.read(IMG_B));
    ImageMLData inputImage3 = new ImageMLData(ImageIO.read(IMG_C));
   
    BasicMLData idealImage1 = new BasicMLData(new double[]{1.0,0.0,0.0});
    BasicMLData idealImage2 = new BasicMLData(new double[]{0.0,1.0,0.0});
    BasicMLData idealImage3 = new BasicMLData(new double[]{0.0,0.0,1.0});
   
    training.add(inputImage1,idealImage1);
    training.add(inputImage2,idealImage2);
    training.add(inputImage3,idealImage3);
   
View Full Code Here

    g.fillRect(0, 0, 5, 5);
    g.dispose();
   
    Downsample downsample = new SimpleIntensityDownsample();
    ImageMLDataSet set = new ImageMLDataSet(downsample,true,-1,1);
    BasicMLData ideal = new BasicMLData(1);
    ImageMLData input = new ImageMLData(image);
    set.add(input,ideal);
    set.downsample(2,2);
    Iterator<MLDataPair> itr = set.iterator();
    MLDataPair pair = (MLDataPair)itr.next();
View Full Code Here

    }

    final ExpressionValue v = this.rootNode.evaluate();
    final VariableMapping resultMapping = getResultType();

    final MLData result = new BasicMLData(1);
    boolean success = false;

    switch (resultMapping.getVariableType()) {
    case floatingType:
      if (v.isNumeric()) {
        result.setData(0, v.toFloatValue());
        success = true;
      }
      break;
    case stringType:
      result.setData(0, v.toFloatValue());
      success = true;
      break;
    case booleanType:
      if (v.isBoolean()) {
        result.setData(0, v.toBooleanValue() ? 1.0 : 0.0);
        success = true;
      }
      break;
    case intType:
      if (v.isNumeric()) {
        result.setData(0, v.toIntValue());
        success = true;
      }
      break;
    case enumType:
      if (v.isEnum()) {
        result.setData(0, v.toIntValue());
        success = true;
      }
      break;
    }
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.