Package org.encog.neural.networks

Examples of org.encog.neural.networks.BasicNetwork


    }
  }

  public void performClose() {
    if (this.prune != null) {
      BasicNetwork network = this.prune.getBestNetwork();

      if (network != null) {
        if (EncogWorkBench.askQuestion("Network",
            "Do you wish to save this network?")) {
          if (network != null) {
View Full Code Here


      this.activationOutput = this.activationHidden;
   
    final Layer input = new BasicLayer(null, true,
        this.inputNeurons);

    final BasicNetwork result = new BasicNetwork();
    result.addLayer(input);


    for (final Integer count : this.hidden) {

      final Layer hidden = new BasicLayer(this.activationHidden, true, count);

      result.addLayer(hidden);
    }

    final Layer output = new BasicLayer(this.activationOutput, false,
        this.outputNeurons);
    result.addLayer(output);

    result.getStructure().finalizeStructure();
    result.reset();

    return result;
  }
View Full Code Here

   *            Contains information about the job unit.
   */
  @Override
  public final void performJobUnit(final JobUnitContext context) {

    final BasicNetwork network = (BasicNetwork) context.getJobUnit();
    BufferedNeuralDataSet buffer = null;
    MLDataSet useTraining = this.training;

    if (this.training instanceof BufferedNeuralDataSet) {
      buffer = (BufferedNeuralDataSet) this.training;
      useTraining = buffer.openAdditional();
    }

    // train the neural network

    double error = Double.POSITIVE_INFINITY;
    for (int z = 0; z < this.weightTries; z++) {
      network.reset();
      final Propagation train = new ResilientPropagation(network,
          useTraining);
      final StopTrainingStrategy strat = new StopTrainingStrategy(0.001,
          5);

      train.addStrategy(strat);
      train.setNumThreads(1); // force single thread mode

      for (int i = 0; (i < this.iterations) && !getShouldStop()
          && !strat.shouldStop(); i++) {
        train.iteration();
      }

      error = Math.min(error, train.getError());
    }

    if (buffer != null) {
      buffer.close();
    }

    if (!getShouldStop()) {
      // update min and max

      this.high = Math.max(this.high, error);
      this.low = Math.min(this.low, error);

      if (this.hidden1Size > 0) {
        int networkHidden1Count;
        int networkHidden2Count;

        if (network.getLayerCount() > 3) {
          networkHidden2Count = network.getLayerNeuronCount(1);
          networkHidden1Count = network.getLayerNeuronCount(2);
        } else {
          networkHidden2Count = 0;
          networkHidden1Count = network.getLayerNeuronCount(1);
        }

        int row, col;

        if (this.hidden2Size == 0) {
View Full Code Here

  public final Object requestNextTask() {
    if (this.done || getShouldStop()) {
      return null;
    }

    final BasicNetwork network = generateNetwork();

    if (!increaseHiddenCounts()) {
      this.done = true;
    }
View Full Code Here

    }

    // now select the best network, which is the most simple of the
    // top networks.

    BasicNetwork choice = null;

    for (final BasicNetwork n : this.topNetworks) {
      if (n == null) {
        continue;
      }

      if (choice == null) {
        choice = n;
      } else {
        if (n.getStructure().calculateSize() < choice.getStructure()
            .calculateSize()) {
          choice = n;
        }
      }
    }
View Full Code Here

   * Generate the network.
   *
   * @return The generated network.
   */
  public final MLMethod generate() {
    final BasicNetwork network = new BasicNetwork();

    final Layer inputLayer = new BasicLayer(new ActivationLinear(), true,
        this.inputNeurons);
    final Layer outputLayer = new BasicLayer(new ActivationLinear(), false,
        this.outputNeurons);

    network.addLayer(inputLayer);
    network.addLayer(outputLayer);
    network.getStructure().finalizeStructure();

    (new RangeRandomizer(-0.5, 0.5)).randomize(network);

    return network;
  }
View Full Code Here

    getGenetic().setCrossover(
        new Splice(network.getStructure().calculateSize() / 3));
    getGenetic().setMutate(new MutatePerturb(4.0));
    getGenetic().setPopulation(population);
    for (int i = 0; i < population.getPopulationSize(); i++) {
      final BasicNetwork chromosomeNetwork = (BasicNetwork) network
          .clone();
      randomizer.randomize(chromosomeNetwork);

      final NeuralGenome genome = new NeuralGenome(chromosomeNetwork);
      genome.setGeneticAlgorithm(getGenetic());
View Full Code Here

    int failureCount = 0;
   
    for(int i=0;i<1000;i++) {
      // create a neural network, without using a factory
      BasicNetwork network = new BasicNetwork();
      network.addLayer(new BasicLayer(null, false, 2));
      network.addLayer(new BasicLayer(new ActivationSigmoid(), true, 3));
      network.addLayer(new BasicLayer(new ActivationSigmoid(), true, 1));
      network.getStructure().finalizeStructure();
      network.reset();
      (new ConsistentRandomizer(0,0.5,i)).randomize(network);

      // create training data
      MLDataSet trainingSet = new BasicMLDataSet(XOR_INPUT, XOR_IDEAL);
View Full Code Here

    return temp.process(this.normalizedSunspots);
  }
 
  public BasicNetwork createNetwork()
  {
    BasicNetwork network = new BasicNetwork();
    network.addLayer(new BasicLayer(WINDOW_SIZE));
    network.addLayer(new BasicLayer(10));
    network.addLayer(new BasicLayer(1));
    network.getStructure().finalizeStructure();
    network.reset();
    return network;
  }
View Full Code Here

  }
 
  public void run()
  {
    normalizeSunspots(0.1,0.9);
    BasicNetwork network = createNetwork();
    MLDataSet training = generateTraining();
    train(network,training);
    predict(network);
   
  }
View Full Code Here

TOP

Related Classes of org.encog.neural.networks.BasicNetwork

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.