Package org.encog.neural.networks

Examples of org.encog.neural.networks.BasicNetwork


  public void randomize(MLMethod method) {
    if( !(method instanceof BasicNetwork) ) {
      throw new EncogError("Nguyen-Widrow only supports BasicNetwork.");
    }
   
    BasicNetwork network = (BasicNetwork)method;
   
    for(int fromLayer=0; fromLayer<network.getLayerCount()-1; fromLayer++) {
      randomizeSynapse(network, fromLayer);
    }
   
  }
View Full Code Here


    this.activation=activation;
  }

  @Override
  public MLMethod createML(int inputs, int outputs) {
    BasicNetwork network = new BasicNetwork();
    network.addLayer(new BasicLayer(activation,false,inputs)); //(inputs));
    for (Integer layerSize: layers)
      network.addLayer(new BasicLayer(activation,true,layerSize));
    network.addLayer(new BasicLayer(activation,true,outputs));
    network.getStructure().finalizeStructure();
    network.reset();
    return network;
  }
View Full Code Here

  public final File EG_FILENAME = TEMP_DIR.createFile("encogtest.eg");
  public final File SERIAL_FILENAME = TEMP_DIR.createFile("encogtest.ser");

  public void testRPROPCont() {
    MLDataSet trainingSet = XOR.createXORDataSet();
    BasicNetwork net1 = XOR.createUnTrainedXOR();
    BasicNetwork net2 = XOR.createUnTrainedXOR();
   
    ResilientPropagation rprop1 = new ResilientPropagation(net1,trainingSet);
    ResilientPropagation rprop2 = new ResilientPropagation(net2,trainingSet);
   
    rprop1.iteration();
    rprop1.iteration();
   
    rprop2.iteration();
    rprop2.iteration();
   
    TrainingContinuation cont = rprop2.pause();
   
    ResilientPropagation rprop3 = new ResilientPropagation(net2,trainingSet);
    rprop3.resume(cont);
   
    rprop1.iteration();
    rprop3.iteration();
   
   
    for(int i=0;i<net1.getFlat().getWeights().length;i++) {
      Assert.assertEquals(net1.getFlat().getWeights()[i], net2.getFlat().getWeights()[i],0.0001);
    }
  }
View Full Code Here

    }
  }
 
  public void testRPROPContPersistEG() {
    MLDataSet trainingSet = XOR.createXORDataSet();
    BasicNetwork net1 = XOR.createUnTrainedXOR();
    BasicNetwork net2 = XOR.createUnTrainedXOR();
   
    ResilientPropagation rprop1 = new ResilientPropagation(net1,trainingSet);
    ResilientPropagation rprop2 = new ResilientPropagation(net2,trainingSet);
   
    rprop1.iteration();
    rprop1.iteration();
   
    rprop2.iteration();
    rprop2.iteration();
   
    TrainingContinuation cont = rprop2.pause();
   
    EncogDirectoryPersistence.saveObject(EG_FILENAME, cont);
    TrainingContinuation cont2 = (TrainingContinuation)EncogDirectoryPersistence.loadObject(EG_FILENAME);
   
    ResilientPropagation rprop3 = new ResilientPropagation(net2,trainingSet);
    rprop3.resume(cont2);
   
    rprop1.iteration();
    rprop3.iteration();
   
   
    for(int i=0;i<net1.getFlat().getWeights().length;i++) {
      Assert.assertEquals(net1.getFlat().getWeights()[i], net2.getFlat().getWeights()[i],0.0001);
    }
  }
View Full Code Here

  @Test
  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(trainingData,rprop,0.03);
  }
View Full Code Here

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

  @Test
  public void testBPROP() throws Throwable
  {
    MLDataSet trainingData = new BasicMLDataSet(XOR.XOR_INPUT,XOR.XOR_IDEAL);
   
    BasicNetwork network = NetworkUtil.createXORNetworkUntrained();

    MLTrain bprop = new Backpropagation(network, trainingData, 0.7, 0.9);
    NetworkUtil.testTraining(trainingData,bprop,0.01);
  }
View Full Code Here

  @Test
  public void testManhattan() throws Throwable
  {
    MLDataSet trainingData = new BasicMLDataSet(XOR.XOR_INPUT,XOR.XOR_IDEAL);
   
    BasicNetwork network = NetworkUtil.createXORNetworkUntrained();
    MLTrain bprop = new ManhattanPropagation(network, trainingData, 0.01);
    NetworkUtil.testTraining(trainingData,bprop,0.01);
  }
View Full Code Here

  @Test
  public void testSCG() throws Throwable
  {
    MLDataSet trainingData = new BasicMLDataSet(XOR.XOR_INPUT,XOR.XOR_IDEAL);
   
    BasicNetwork network = NetworkUtil.createXORNetworkUntrained();
    MLTrain bprop = new ScaledConjugateGradient(network, trainingData);
    NetworkUtil.testTraining(trainingData,bprop,0.04);
  }
View Full Code Here

 
  @Test
  public void testAnneal() throws Throwable
  {
    MLDataSet trainingData = new BasicMLDataSet(XOR.XOR_INPUT,XOR.XOR_IDEAL);   
    BasicNetwork network = NetworkUtil.createXORNetworkUntrained();
    CalculateScore score = new TrainingSetScore(trainingData);
    NeuralSimulatedAnnealing anneal = new NeuralSimulatedAnnealing(network,score,10,2,100);
    NetworkUtil.testTraining(trainingData,anneal,0.01);
  }
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.