Examples of MLDataPair


Examples of org.encog.ml.data.MLDataPair

  @Override
  public final boolean read(final double[] input, final double[] ideal, final double[] significance) {
    if (!iterator.hasNext()) {
      return false;
    } else {
      MLDataPair pair = iterator.next();
      EngineArray.arrayCopy(pair.getInputArray(), input);
      EngineArray.arrayCopy(pair.getIdealArray(), ideal);
      significance[0] = pair.getSignificance();
      return true;
    }
  }
View Full Code Here

Examples of org.encog.ml.data.MLDataPair

  /**
   * {@inheritDoc}
   */
  @Override
  public final void write(final double[] input, final double[] ideal, double significance) {
    MLDataPair pair = BasicMLDataPair.createPair(inputSize,
        idealSize);
    EngineArray.arrayCopy(input, pair.getIdealArray());
    EngineArray.arrayCopy(ideal, pair.getIdealArray());
    pair.setSignificance(significance);
  }
View Full Code Here

Examples of org.encog.ml.data.MLDataPair

    final long start = System.currentTimeMillis();
    final long stop = start + (10 * Evaluate.MILIS);
    int record = 0;

    MLDataPair pair = BasicMLDataPair.createPair(10, 10);

    int iterations = 0;
    while (System.currentTimeMillis() < stop) {
      iterations++;
      training.getRecord(record++, pair);
View Full Code Here

Examples of org.encog.ml.data.MLDataPair

    final long start = System.currentTimeMillis();
    final long stop = start + (10 * Evaluate.MILIS);
    int record = 0;

    MLDataPair pair = BasicMLDataPair.createPair(10, 10);

    int iterations = 0;
    while (System.currentTimeMillis() < stop) {
      iterations++;
      training2.getRecord(record++, pair);
View Full Code Here

Examples of org.encog.ml.data.MLDataPair

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

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

      currentRecord++;
      lastUpdate++;
      if (lastUpdate >= 10000) {
View Full Code Here

Examples of org.encog.ml.data.MLDataPair

   
    final long start = System.currentTimeMillis();
    final long stop = start + (10*Evaluate.MILIS);
    int record = 0;
   
    MLDataPair pair = BasicMLDataPair.createPair(10, 10);
   
    int iterations = 0;
    while( System.currentTimeMillis()<stop ) {
      iterations++;
      training.getRecord(record++, pair)
View Full Code Here

Examples of org.encog.ml.data.MLDataPair

   
    final long start = System.currentTimeMillis();
    final long stop = start + (10*Evaluate.MILIS);
    int record = 0;
   
    MLDataPair pair = BasicMLDataPair.createPair(10, 10);
   
    int iterations = 0;
    while( System.currentTimeMillis()<stop ) {
      iterations++;
      training2.getRecord(record++, pair)
View Full Code Here

Examples of org.encog.ml.data.MLDataPair

      }
    }

    this.network.setExclude((int) training.getRecordCount());

    final MLDataPair pair = BasicMLDataPair.createPair(
        training.getInputSize(), training.getIdealSize());

    final double[] out = new double[this.network.getOutputCount()];

    for (int r = 0; r < training.getRecordCount(); r++) {
      training.getRecord(r, pair);
      this.network.setExclude(this.network.getExclude() - 1);

      err = 0.0;

      final MLData input = pair.getInput();
      final MLData target = pair.getIdeal();

      if (this.network.getOutputMode() == PNNOutputMode.Unsupervised) {
        if (deriv) {
          final MLData output = computeDeriv(input, target);
          for (int z = 0; z < this.network.getOutputCount(); z++) {
            out[z] = output.getData(z);
          }
        } else {
          final MLData output = this.network.compute(input);
          for (int z = 0; z < this.network.getOutputCount(); z++) {
            out[z] = output.getData(z);
          }
        }
        for (int i = 0; i < this.network.getOutputCount(); i++) {
          diff = input.getData(i) - out[i];
          err += diff * diff;
        }
      } else if (this.network.getOutputMode() == PNNOutputMode.Classification) {
        final int tclass = (int) target.getData(0);
        MLData output;

        if (deriv) {
          output = computeDeriv(input, pair.getIdeal());
          output.getData(0);
        } else {
          output = this.network.compute(input);
          output.getData(0);
        }
View Full Code Here

Examples of org.encog.ml.data.MLDataPair

        this.v[vsptr + ivar] = 0.0;
        this.w[wsptr + ivar] = 0.0;
      }
    }

    final MLDataPair pair = BasicMLDataPair.createPair(this.network
        .getSamples().getInputSize(), this.network.getSamples()
        .getIdealSize());

    for (int r = 0; r < this.network.getSamples().getRecordCount(); r++) {

      this.network.getSamples().getRecord(r, pair);

      if (r == this.network.getExclude()) {
        continue;
      }

      dist = 0.0;
      for (ivar = 0; ivar < this.network.getInputCount(); ivar++) {
        diff = input.getData(ivar) - pair.getInput().getData(ivar);
        diff /= this.network.getSigma()[ivar];
        this.dsqr[ivar] = diff * diff;
        dist += this.dsqr[ivar];
      }

      if (this.network.getKernel() == PNNKernelType.Gaussian) {
        dist = Math.exp(-dist);
      } else if (this.network.getKernel() == PNNKernelType.Reciprocal) {
        dist = 1.0 / (1.0 + dist);
      }

      truedist = dist;
      if (dist < 1.e-40) {
        dist = 1.e-40;
      }

      if (this.network.getOutputMode() == PNNOutputMode.Classification) {
        pop = (int) pair.getIdeal().getData(0);
        out[pop] += dist;
        vptr = pop * this.network.getInputCount();
        wptr = pop * this.network.getInputCount();
        for (ivar = 0; ivar < this.network.getInputCount(); ivar++) {
          temp = truedist * this.dsqr[ivar];
          this.v[vptr + ivar] += temp;
          this.w[wptr + ivar] += temp * (2.0 * this.dsqr[ivar] - 3.0);
        }
      }

      else if (this.network.getOutputMode() == PNNOutputMode.Unsupervised) {
        for (ivar = 0; ivar < this.network.getInputCount(); ivar++) {
          out[ivar] += dist * pair.getInput().getData(ivar);
          temp = truedist * this.dsqr[ivar];
          this.v[vsptr + ivar] += temp;
          this.w[wsptr + ivar] += temp
              * (2.0 * this.dsqr[ivar] - 3.0);
        }
        vptr = 0;
        wptr = 0;
        for (outvar = 0; outvar < this.network.getOutputCount(); outvar++) {
          for (ivar = 0; ivar < this.network.getInputCount(); ivar++) {
            temp = truedist * this.dsqr[ivar]
                * pair.getInput().getData(ivar);
            this.v[vptr++] += temp;
            this.w[wptr++] += temp * (2.0 * this.dsqr[ivar] - 3.0);
          }
        }
        psum += dist;
      } else if (this.network.getOutputMode() == PNNOutputMode.Regression) {

        for (ivar = 0; ivar < this.network.getOutputCount(); ivar++) {
          out[ivar] += dist * pair.getIdeal().getData(ivar);
        }
        vptr = 0;
        wptr = 0;
        for (outvar = 0; outvar < this.network.getOutputCount(); outvar++) {
          for (ivar = 0; ivar < this.network.getInputCount(); ivar++) {
            temp = truedist * this.dsqr[ivar]
                * pair.getIdeal().getData(outvar);
            this.v[vptr++] += temp;
            this.w[wptr++] += temp * (2.0 * this.dsqr[ivar] - 3.0);
          }
        }
        for (ivar = 0; ivar < this.network.getInputCount(); ivar++) {
View Full Code Here

Examples of org.encog.ml.data.MLDataPair

          final MLData idealData = new BasicMLData(inputCount);
          for (int i = 0; i < outputCount; i++) {
            idealData.setData(i,
                CSVFormat.EG_FORMAT.parse(cols.get(index++)));
          }
          final MLDataPair pair = new BasicMLDataPair(inputData,
              idealData);
          samples.add(pair);
        }
      }
    }
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.