Package org.encog.neural.rbf

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


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

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

        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

  }
 
  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

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

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

    return result;
  }
View Full Code Here

    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

    }
   
    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

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

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

    return result;
  }
View Full Code Here

    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

  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

TOP

Related Classes of org.encog.neural.rbf.RBFNetwork

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.