Package tv.floe.metronome.classification.neuralnetworks.networks

Examples of tv.floe.metronome.classification.neuralnetworks.networks.MultiLayerPerceptronNetwork


    c.setConfValue("neuronType", Neuron.class);
    c.setConfValue("networkType", NeuralNetwork.NetworkType.MULTI_LAYER_PERCEPTRON);
    c.setConfValue("layerNeuronCounts", "2,3,1" );
    c.parse(null);
   
    MultiLayerPerceptronNetwork mlp_network = new MultiLayerPerceptronNetwork();
   
   
   
//    int[] neurons = { 2, 3, 1 };
//    c.setLayerNeuronCounts( neurons );
   
    mlp_network.buildFromConf(c);   
   
    return mlp_network;
  }
View Full Code Here


    vec.set(12);
   
    Config c = new Config();
    c.parse(null); // default layer: 2-3-2
   
    MultiLayerPerceptronNetwork mlp_network = new MultiLayerPerceptronNetwork();
   
    mlp_network.buildFromConf(c);
   

    mlp_network.setInputVector(vec);
   
    //mlp_network.
   
    Layer l0 = mlp_network.getLayerByIndex(0);
   
    assertEquals( 2, l0.getNeurons().size() );
   
    assertEquals(0, l0.getNeuronAt(0).getInConnections().size() );
    assertEquals(0, l0.getNeuronAt(1).getInConnections().size() );

    assertEquals(3, l0.getNeuronAt(0).getOutConnections().size() );
    assertEquals(3, l0.getNeuronAt(1).getOutConnections().size() );

   
   
    Layer l1 = mlp_network.getLayerByIndex(1);

    assertEquals( 3, l1.getNeurons().size() );
   
    assertEquals(2, l1.getNeuronAt(0).getInConnections().size() );
    assertEquals(2, l1.getNeuronAt(1).getInConnections().size() );
    assertEquals(2, l1.getNeuronAt(2).getInConnections().size() );

    assertEquals(2, l1.getNeuronAt(0).getOutConnections().size() );
    assertEquals(2, l1.getNeuronAt(1).getOutConnections().size() );
    assertEquals(2, l1.getNeuronAt(2).getOutConnections().size() );
   
   
   
    Layer l2 = mlp_network.getLayerByIndex(2);
   
    assertEquals( 2, l2.getNeurons().size() );
   
    assertEquals(3, l2.getNeuronAt(0).getInConnections().size() );
    assertEquals(3, l2.getNeuronAt(1).getInConnections().size() );
View Full Code Here

  }
 
 
  public static MultiLayerPerceptronNetwork loadModelFromDisk() {
   
    MultiLayerPerceptronNetwork nnet = null;
   
    try {

      Path out = new Path("/tmp/nn.model");
      FileSystem fs =
View Full Code Here

 
 
  public static void scoreIrisNeuralNetworkModel(String modelFileLocation) throws Exception {
   
    // load model
    MultiLayerPerceptronNetwork mlp = loadModelFromDisk();
   
    //Utils.PrintNeuralNetwork(  mlp );
   
    //System.out.println("Layers: " + mlp.getLayersCount());
   
    MetronomeRecordFactory rec_factory = new MetronomeRecordFactory("i:4 | o:3");
 
     
      String recs = "src/test/resources/data/uci/iris/iris_data_normalised.mne";
      Vector v_in_0 = new RandomAccessSparseVector(rec_factory.getInputVectorSize());
      Vector v_out_0 = new RandomAccessSparseVector(rec_factory.getOutputVectorSize());
     
     
     
      int total_recs = 0;
      int correct = 0;
     
      BufferedReader br = new BufferedReader(new FileReader(recs));
      String line;
      while ((line = br.readLine()) != null) {
       
       

        rec_factory.vectorizeLine( line, v_in_0, v_out_0 );
       
        if (isCorrect(mlp, v_in_0, v_out_0) ) {
          correct++;
        }
        total_recs++;
       
        //System.out.println("rec > " + line);
        //System.out.println("out > " + v_out_0.toString());
       
      }
      br.close();   
     
      BackPropogationLearningAlgorithm bp = ((BackPropogationLearningAlgorithm)mlp.getLearningRule());
     
      System.out.println("Avg RMSE: " + bp.getMetrics().getLastRMSE());
      System.out.println("Total: " + total_recs);
      System.out.println("Correct: " + correct);
   
View Full Code Here

    c.setConfValue("neuronType", Neuron.class);
    c.setConfValue("networkType", NeuralNetwork.NetworkType.MULTI_LAYER_PERCEPTRON);
    c.setConfValue("layerNeuronCounts", "2,3,1" );
   
   
    MultiLayerPerceptronNetwork mlp_network = new MultiLayerPerceptronNetwork();
   
   
   

//    mlp_network.setInputVector(vec);
   
    int[] neurons = { 2, 3, 1 };
    c.setLayerNeuronCounts( neurons );
   
    mlp_network.buildFromConf(c);
       
   
    for ( int x = 0; x < 40000; x++ ) {
     
     
         

      mlp_network.train(v0_out, v0);
      mlp_network.train(v1_out, v1);
      mlp_network.train(v2_out, v2);
      mlp_network.train(v3_out, v3);

     
      int total_records = 0;
      int number_correct = 0;
         
      total_records++;
     
     
      mlp_network.setInputVector( v0 );
      mlp_network.calculate();
            Vector networkOutput = mlp_network.getOutputVector();

            System.out.println( "> out: 0 =? " + networkOutput.get(0) );
               
           
           
      mlp_network.setInputVector( v1 );
      mlp_network.calculate();
            Vector networkOutput_1 = mlp_network.getOutputVector();

            System.out.println( "> out: 1 =? " + networkOutput_1.get(0) );
                   

      mlp_network.setInputVector( v2 );
      mlp_network.calculate();
            Vector networkOutput_2 = mlp_network.getOutputVector();

            System.out.println( "> out: 1 =? " + networkOutput_2.get(0) );


      mlp_network.setInputVector( v3 );
      mlp_network.calculate();
            Vector networkOutput_3 = mlp_network.getOutputVector();

            System.out.println( "> out: 0 =? " + networkOutput_3.get(0) );
           
           
     
View Full Code Here

    c.setConfValue("neuronType", Neuron.class);
    c.setConfValue("networkType", NeuralNetwork.NetworkType.MULTI_LAYER_PERCEPTRON);
    c.setConfValue("layerNeuronCounts", "2,3,1" );
    c.parse(null);
   
    MultiLayerPerceptronNetwork mlp_network = new MultiLayerPerceptronNetwork();
   
   
   
//    int[] neurons = { 2, 3, 1 };
//    c.setLayerNeuronCounts( neurons );
   
    mlp_network.buildFromConf(c);   
   
    return mlp_network;
  }   
View Full Code Here

  }
 
 
  public static MultiLayerPerceptronNetwork loadModelFromDisk(String model_path) {
   
    MultiLayerPerceptronNetwork nnet = null;
   
    try {

      Path out = new Path(model_path);
      FileSystem fs =
View Full Code Here

  }
 
  public static void scoreIrisNeuralNetworkModel(String modelFileLocation) throws Exception {
   
    // load model
    MultiLayerPerceptronNetwork mlp = loadModelFromDisk(modelFileLocation);
   
    //Utils.PrintNeuralNetwork(  mlp );
   
    //System.out.println("Layers: " + mlp.getLayersCount());
   
View Full Code Here

    c.setConfValue("neuronType", Neuron.class);
    c.setConfValue("networkType", NeuralNetwork.NetworkType.MULTI_LAYER_PERCEPTRON);
    c.setConfValue("layerNeuronCounts", "2,3,1" );
    c.parse(null);
   
    MultiLayerPerceptronNetwork mlp_network = new MultiLayerPerceptronNetwork();
   
   
   
//    int[] neurons = { 2, 3, 1 };
//    c.setLayerNeuronCounts( neurons );
   
    mlp_network.buildFromConf(c);   
   
    return mlp_network;
 
View Full Code Here

    c.setConfValue("neuronType", Neuron.class);
    c.setConfValue("networkType", NeuralNetwork.NetworkType.MULTI_LAYER_PERCEPTRON);
    c.setConfValue("layerNeuronCounts", "2,3,1" );
    c.parse(null);
   
    NeuralNetwork nn = new MultiLayerPerceptronNetwork();
   
    try {
      nn.buildFromConf(c);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
   
View Full Code Here

TOP

Related Classes of tv.floe.metronome.classification.neuralnetworks.networks.MultiLayerPerceptronNetwork

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.