Package org.encog.neural.networks.training.propagation.resilient

Examples of org.encog.neural.networks.training.propagation.resilient.ResilientPropagation


    network.reset();
   
    final MLDataSet training = RandomTrainingFactory.generate(1000,50000,
        INPUT_COUNT, OUTPUT_COUNT, -1, 1);
   
    ResilientPropagation rprop = new ResilientPropagation(network,training);
    rprop.setNumThreads(thread);
    for(int i=0;i<5;i++)
    {
      rprop.iteration();
    }
    long stop = System.currentTimeMillis();
    System.out.println("Result with " + thread + " was " + (stop-start));
  }
View Full Code Here


    network.reset();

    MLDataSet trainingSet = new BasicMLDataSet(XOR_INPUT, XOR_IDEAL);

    // train the neural network
    final MLTrain train = new ResilientPropagation(network, trainingSet);

    do {
      train.iteration();
    } while (train.getError() > 0.009);

    double e = network.calculateError(trainingSet);
    System.out.println("Network traiined to error: " + e);

    System.out.println("Saving network");
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public final void createTrainer(final boolean singleThreaded) {
    final Propagation train = new ResilientPropagation(getNetwork(),
        getTraining(), getInitialUpdate(), getMaxStep());

    if (singleThreaded) {
      train.setNumThreads(1);
    } else {
      train.setNumThreads(0);
    }

    for (final Strategy strategy : getStrategies()) {
      train.addStrategy(strategy);
    }

    setTrain(train);
  }
View Full Code Here

    BasicNetwork network1 = NetworkUtil.createXORNetworkUntrained();
    BasicNetwork network2 = NetworkUtil.createXORNetworkUntrained();
    MLDataSet trainingData = new BasicMLDataSet(XOR.XOR_INPUT,XOR.XOR_IDEAL);
   
    // train network 1, no continue
    ResilientPropagation rprop1 = new ResilientPropagation(network1,trainingData);
    rprop1.iteration();
    rprop1.iteration();
    rprop1.iteration();
    rprop1.iteration();
   
    // train network 2, continue
    ResilientPropagation rprop2 = new ResilientPropagation(network2,trainingData);
    rprop2.iteration();
    rprop2.iteration();
    TrainingContinuation state = rprop2.pause();
    rprop2 = new ResilientPropagation(network2,trainingData);
    rprop2.resume(state);
    rprop2.iteration();
    rprop2.iteration();
   
    // verify weights are the same
    double[] weights1 = NetworkCODEC.networkToArray(network1);
    double[] weights2 = NetworkCODEC.networkToArray(network2);
   
    Assert.assertEquals(rprop1.getError(), rprop2.getError(), 0.01);
    Assert.assertEquals(weights1.length, weights2.length);
    Assert.assertArrayEquals(weights1, weights2, 0.01);
   
  }
View Full Code Here

    network2.setBiasActivation(-1);
    network3.setBiasActivation(0.5);
   
    MLDataSet trainingData = new BasicMLDataSet(XOR.XOR_INPUT,XOR.XOR_IDEAL);
   
    MLTrain rprop1 = new ResilientPropagation(network1, trainingData);
    MLTrain rprop2 = new ResilientPropagation(network2, trainingData);
    MLTrain rprop3 = new ResilientPropagation(network3, trainingData);

    NetworkUtil.testTraining(rprop1,0.03);
    NetworkUtil.testTraining(rprop2,0.01);
    NetworkUtil.testTraining(rprop3,0.01);
   
View Full Code Here

   
    BasicNetwork network = EncogUtility.simpleFeedForward(2, 5, 7, 1, true);
    Randomizer randomizer = new ConsistentRandomizer(-1, 1, 19);
    //randomizer.randomize(network);
    System.out.println(network.dumpWeights());
    MLTrain rprop = new ResilientPropagation(network, trainingData);
    int iteration = 0;
    do {
      rprop.iteration();
      System.out.println(rprop.getError());
      iteration++;
    } while( iteration<5000 && rprop.getError()>0.01);
    System.out.println(iteration);
    Assert.assertTrue(iteration<40);
  }
View Full Code Here

  public void testRPROP() throws Throwable
  {
    MLDataSet trainingData = new BasicMLDataSet(XOR.XOR_INPUT,XOR.XOR_IDEAL);
   
    BasicNetwork network = NetworkUtil.createXORNetworkUntrained();
    MLTrain rprop = new ResilientPropagation(network, trainingData);
    NetworkUtil.testTraining(rprop,0.03);
  }
View Full Code Here

    elmanPattern.setInputNeurons(input);
    elmanPattern.addHiddenLayer(hidden);
    elmanPattern.setOutputNeurons(ideal);
    BasicNetwork network = (BasicNetwork)elmanPattern.generate();
    MLDataSet training = RandomTrainingFactory.generate(1000, 5, network.getInputCount(), network.getOutputCount(), -1, 1);
    ResilientPropagation prop = new ResilientPropagation(network,training);
    prop.iteration();
    prop.iteration();   
  }
View Full Code Here

    jordanPattern.setInputNeurons(input);
    jordanPattern.addHiddenLayer(hidden);
    jordanPattern.setOutputNeurons(ideal);
    BasicNetwork network = (BasicNetwork)jordanPattern.generate();
    MLDataSet training = RandomTrainingFactory.generate(1000, 5, network.getInputCount(), network.getOutputCount(), -1, 1);
    ResilientPropagation prop = new ResilientPropagation(network,training);
    prop.iteration();
    prop.iteration();   
  }
View Full Code Here

  public void testLimited()
  {
    MLDataSet trainingData = new BasicMLDataSet(XOR.XOR_INPUT,XOR.XOR_IDEAL);
    BasicNetwork network = NetworkUtil.createXORNetworkUntrained();   
   
    ResilientPropagation rprop = new ResilientPropagation(network,trainingData);
    rprop.iteration();
    rprop.iteration();
    network.enableConnection(1, 0, 0, false);
    network.enableConnection(1, 1, 0, false);
   
    Assert.assertTrue(network.getStructure().isConnectionLimited());
   
    Assert.assertEquals(0.0, network.getStructure().getFlat().getWeights()[0], 0.01);
    Assert.assertEquals(0.0, network.getStructure().getFlat().getWeights()[1], 0.01);
    rprop.iteration();
    rprop.iteration();
    rprop.iteration();
    rprop.iteration();
    // these connections were removed, and should not have been "trained"
    Assert.assertEquals(0.0, network.getStructure().getFlat().getWeights()[0], 0.01);
    Assert.assertEquals(0.0, network.getStructure().getFlat().getWeights()[1], 0.01);   
    rprop.finishTraining();
  }
View Full Code Here

TOP

Related Classes of org.encog.neural.networks.training.propagation.resilient.ResilientPropagation

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.