Examples of RbfNetwork


Examples of com.heatonresearch.aifh.learning.RBFNetwork

        // Create random particles for the RBF.
        GenerateRandom rnd = new MersenneTwisterGenerateRandom();
        RBFNetwork[] particles = new RBFNetwork[TitanicConfig.ParticleCount];
        for (int i = 0; i < particles.length; i++) {
            particles[i] = new RBFNetwork(TitanicConfig.InputFeatureCount, TitanicConfig.RBF_COUNT, 1);
            particles[i].reset(rnd);
        }

        /**
         * Construct a network to hold the best network.
         */
        if (bestNetwork == null) {
            bestNetwork = new RBFNetwork(TitanicConfig.InputFeatureCount, TitanicConfig.RBF_COUNT, 1);
        }

        /**
         * Setup the scoring function.
         */
        ScoreFunction score = new ScoreTitanic(training);
        ScoreFunction scoreValidate = new ScoreTitanic(validation);

        /**
         * Setup particle swarm.
         */
        boolean done = false;
        TrainPSO train = new TrainPSO(particles, score);
        int iterationNumber = 0;
        StringBuilder line = new StringBuilder();

        do {
            iterationNumber++;

            train.iteration();

            RBFNetwork best = (RBFNetwork) train.getBestParticle();

            double trainingScore = train.getLastError();
            double validationScore = scoreValidate.calculateScore(best);

            if (validationScore > bestScore) {
                System.arraycopy(best.getLongTermMemory(), 0, this.bestNetwork.getLongTermMemory(), 0, best.getLongTermMemory().length);
                this.bestScore = validationScore;
            }

            if (validationScore > localBest) {
                noImprove = 0;
View Full Code Here

Examples of com.heatonresearch.aifh.learning.RBFNetwork

            ds.normalizeRange(2, -1, 1);
            ds.normalizeRange(3, -1, 1);
            final Map<String, Integer> species = ds.encodeOneOfN(4);
            istream.close();

            RBFNetwork network = new RBFNetwork(4, 4, 3);

            final List<BasicData> trainingData = ds.extractSupervised(0, 4, 4, 3);

            ScoreFunction score = new ScoreRegressionData(trainingData);
View Full Code Here

Examples of com.heatonresearch.aifh.learning.RBFNetwork

            final Map<String, Integer> species = ds.encodeOneOfN(4);
            istream.close();

            RBFNetwork[] particles = new RBFNetwork[PARTICLE_COUNT];
            for (int i = 0; i < particles.length; i++) {
                particles[i] = new RBFNetwork(4, 4, 3);
                particles[i].reset(rnd);
            }

            final List<BasicData> trainingData = ds.extractSupervised(0, 4, 4, 3);

            ScoreFunction score = new ScoreRegressionData(trainingData);

            TrainPSO train = new TrainPSO(particles, score);

            performIterations(train, 100000, 0.05, true);

            RBFNetwork winner = (RBFNetwork) train.getBestParticle();

            queryOneOfN(winner, trainingData, species);


        } catch (Throwable t) {
View Full Code Here

Examples of org.encog.neural.rbf.RBFNetwork

  public final File SERIAL_FILENAME = TEMP_DIR.createFile("encogtest.ser");
 
  public void testPersistNetworkRBF()
  {
    MLDataSet trainingSet = XOR.createXORDataSet();
    RBFNetwork network = new RBFNetwork(2,4,1, RBFEnum.Gaussian);

    SVDTraining training = new SVDTraining(network,trainingSet);
    training.iteration();
    XOR.verifyXOR(network, 0.1);
   
    EncogDirectoryPersistence.saveObject(EG_FILENAME, network);
    RBFNetwork network2 = (RBFNetwork)EncogDirectoryPersistence.loadObject(EG_FILENAME);

    XOR.verifyXOR(network2, 0.1);   
  }
View Full Code Here

Examples of org.encog.neural.rbf.RBFNetwork

   *
   * @return The neural network.
   */
  public final MLMethod generate() {

    RBFNetwork result = new RBFNetwork(inputNeurons, this.hiddenNeurons ,outputNeurons,this.rbfType);
    return result;
  }
View Full Code Here

Examples of org.encog.neural.rbf.RBFNetwork

        int numNeurons = (int)Math.pow(numNeuronsPerDimension, dimensions);
        int numEdges = (int)(dimensions * Math.pow(2, dimensions - 1));

        pattern.addHiddenLayer(numNeurons);

        RBFNetwork network = (RBFNetwork)pattern.generate();

        //Position the multidimensional RBF neurons, with equal spacing, within the provided sample space from 0 to 1.
        network.setRBFCentersAndWidthsEqualSpacing(0, 1, RBFEnum.Gaussian, volumeNeuronWidth, includeEdgeRBFs);

        //Create some training data that can not easily be represented by gaussians
        //There are other training examples for both 1D and 2D
        //Degenerate training data only provides outputs as 1 or 0 (averaging over all outputs for a given set of inputs would produce something approaching the smooth training data).
        //Smooth training data provides true values for the provided input dimensions.
        create2DSmoothTainingDataGit();

        //Create the training set and train.
        MLDataSet trainingSet = new BasicMLDataSet(INPUT, IDEAL);
        MLTrain train = new SVDTraining(network, trainingSet);

        //SVD is a single step solve
        int epoch = 1;
        do
        {
            train.iteration();
            System.out.println("Epoch #" + epoch + " Error:" + train.getError());
            epoch++;
        } while ((epoch < 1) && (train.getError() > 0.001));

        // test the neural network
        System.out.println("Neural Network Results:");

        //Create a testing array which may be to a higher resoltion than the original training data
        set2DTestingArrays(100);
        trainingSet = new BasicMLDataSet(INPUT, IDEAL);

        FileWriter outFile = new FileWriter("results.csv");
        PrintWriter out = new PrintWriter(outFile);
       
       
            for (MLDataPair pair : trainingSet)
            {
                MLData output = network.compute(pair.getInput());
                //1D//sw.WriteLine(InverseScale(pair.Input[0]) + ", " + Chop(InverseScale(output[0])));// + ", " + pair.Ideal[0]);
                out.println(inverseScale(pair.getInputArray()[0]) + ", " + inverseScale(pair.getInputArray()[1]) + ", " + chop(inverseScale(output.getData(0))));// + ", " + pair.Ideal[0]);// + ",ideal=" + pair.Ideal[0]);
                //3D//sw.WriteLine(InverseScale(pair.Input[0]) + ", " + InverseScale(pair.Input[1]) + ", " + InverseScale(pair.Input[2]) + ", " + Chop(InverseScale(output[0])));// + ", " + pair.Ideal[0]);// + ",ideal=" + pair.Ideal[0]);
                //Console.WriteLine(pair.Input[0] + ", actual=" + output[0] + ",ideal=" + pair.Ideal[0]);
            }
View Full Code Here

Examples of org.encog.neural.rbf.RBFNetwork

  }
 
  public void testFactoryRBF() {
    String architecture = "?->GAUSSIAN(c=4)->?";
    MLMethodFactory factory = new MLMethodFactory();
    RBFNetwork network = (RBFNetwork)factory.create(MLMethodFactory.TYPE_RBFNETWORK, architecture, 1, 4);
    Assert.assertEquals(1,network.getInputCount());
    Assert.assertEquals(4,network.getOutputCount());
    Assert.assertEquals(4,network.getRBF().length)
  }
View Full Code Here

Examples of org.encog.neural.rbf.RBFNetwork

      t = RBFEnum.MexicanHat;
    } else {
      t = RBFEnum.Gaussian;
    }

    final RBFNetwork result = new RBFNetwork(inputCount,
        rbfLayer.getCount(), outputCount, t);

    return result;
  }
View Full Code Here

Examples of org.encog.neural.rbf.RBFNetwork

    final ParamsHolder holder = new ParamsHolder(rbfLayer.getParams());

    final int rbfCount = holder.getInt("C", true, 0);

    final RBFNetwork result = new RBFNetwork(inputCount, rbfCount,
        outputCount, t);

    return result;
  }
View Full Code Here

Examples of org.encog.neural.rbf.RBFNetwork

    }
   
    report.endTable();
   
    if (this.method instanceof RBFNetwork) {
      RBFNetwork rbfNetwork = (RBFNetwork)this.method;
     
      report.h3("RBF Centers");
      report.beginTable();
      report.beginRow();
      report.header("RBF");
      report.header("Peak");
      report.header("Width");
      for(int i=1;i<=rbfNetwork.getInputCount();i++) {
        report.header("Center " + i);
      }
      report.endRow();
     
     
      for( RadialBasisFunction rbf : rbfNetwork.getRBF() ) {
        report.beginRow();
        report.cell(rbf.getClass().getSimpleName());
        report.cell(Format.formatDouble(rbf.getPeak(), 5));
        report.cell(Format.formatDouble(rbf.getWidth(), 5));
        for(int i=0;i<rbfNetwork.getInputCount();i++) {
          report.cell(Format.formatDouble(rbf.getCenter(i), 5));
        }
        report.endRow();
      }
    }
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.