Package org.neuroph.core

Examples of org.neuroph.core.Layer


    promoLayerIdx = 4,
    outputLayerIdx = 5;

  public RecommenderNetwork() {
        for(int i = 0; i < 6; i++)
            this.addLayer(new Layer());
    //this.createDemoNetwork();
 
View Full Code Here


    neuronProperties.setProperty("transferFunction", TransferFunctionType.RAMP);
    // for sigmoid and tanh transfer functions
    neuronProperties.setProperty("transferFunction.slope", new Double(1));
   
    // create input layer   
    Layer inputLayer = LayerFactory.createLayer(productsCount,
        neuronProperties);
    this.addLayer(inputLayer);
    createProductLabels(inputLayer);

   
    // create product types layer   
    Layer typeLayer = LayerFactory.createLayer(typesCount,
        neuronProperties);
    createTypeLabels(typeLayer);
    this.addLayer(typeLayer);
   
   
    // create brands layer   
    Layer brandLayer = LayerFactory.createLayer(brandsCount,
        neuronProperties);
    createBrandLabels(brandLayer);
    this.addLayer(brandLayer)
   
   
    // create price layer   
    Layer priceLayer = LayerFactory.createLayer(priceCount, neuronProperties);
    createPriceLabels(priceLayer);
    this.addLayer(priceLayer)
   
    // create price layer   
    Layer promoLayer = LayerFactory.createLayer(promoCount, neuronProperties);
    createPromoLabels(promoLayer);
    this.addLayer(promoLayer);   
       
    // create output layer
    Layer outputLayer = LayerFactory.createLayer(productsCount,
        neuronProperties);
    this.addLayer(outputLayer);
    createProductLabels(outputLayer);
   
    createTypeConnections();
View Full Code Here

    }

    // creates jets and sharks IAC example
    private void createNetwork() {
        // napraviti elegantni api za kreiranje vise layera NeuralNetwork.createLayers(6); // creates 6 empty layers
        this.addLayer(new Layer())// Name
        this.addLayer(new Layer())// Gang
        this.addLayer(new Layer())// Age
        this.addLayer(new Layer())// Education
        this.addLayer(new Layer())// Marital Status
        this.addLayer(new Layer())// Occupation
       
        this.addLayer(new Layer())// Associations

        Layer layer = this.getLayerAt(0);
       
        IACNeuron neuron = new IACNeuron();
        neuron.setLabel("Art");
        layer.addNeuron(neuron);

        neuron = new IACNeuron();
        neuron.setLabel("Rick");
        layer.addNeuron(neuron);

        neuron = new IACNeuron();
        neuron.setLabel("Sam");
        layer.addNeuron(neuron);

        neuron = new IACNeuron();
        neuron.setLabel("Ralph");
        layer.addNeuron(neuron);

        neuron = new IACNeuron();
        neuron.setLabel("Lance");
        layer.addNeuron(neuron);

        ConnectionFactory.fullConnect(layer, -0.3);
        //----------------------------------------------

        layer = this.getLayerAt(1);

        neuron = new IACNeuron();
        neuron.setLabel("Jets");
        layer.addNeuron(neuron);

        neuron = new IACNeuron();
        neuron.setLabel("Sharks");
        layer.addNeuron(neuron);

        ConnectionFactory.fullConnect(layer, -0.3);

        //----------------------------------------------

        layer = this.getLayerAt(2);

        neuron = new IACNeuron();
        neuron.setLabel("20's");
        layer.addNeuron(neuron);

        neuron = new IACNeuron();
        neuron.setLabel("30's");
        layer.addNeuron(neuron);

        neuron = new IACNeuron();
        neuron.setLabel("40's");
        layer.addNeuron(neuron);

        ConnectionFactory.fullConnect(layer, -0.3);
       
        //----------------------------------------------

        layer = this.getLayerAt(3);

        neuron = new IACNeuron();
        neuron.setLabel("J.H.");
        layer.addNeuron(neuron);

        neuron = new IACNeuron();
        neuron.setLabel("H.S.");
        layer.addNeuron(neuron);

        neuron = new IACNeuron();
        neuron.setLabel("College");
        layer.addNeuron(neuron);

        ConnectionFactory.fullConnect(layer, -0.3);

        //----------------------------------------------

        layer = this.getLayerAt(4);

        neuron = new IACNeuron();
        neuron.setLabel("Single");
        layer.addNeuron(neuron);

        neuron = new IACNeuron();
        neuron.setLabel("Married");
        layer.addNeuron(neuron);

        neuron = new IACNeuron();
        neuron.setLabel("Divorced");
        layer.addNeuron(neuron);

        ConnectionFactory.fullConnect(layer, -0.3);

        //----------------------------------------------

        layer = this.getLayerAt(5);

        neuron = new IACNeuron();
        neuron.setLabel("Pusher");
        layer.addNeuron(neuron);

        neuron = new IACNeuron();
        neuron.setLabel("Burglar");
        layer.addNeuron(neuron);

        neuron = new IACNeuron();
        neuron.setLabel("Bookie");
        layer.addNeuron(neuron);

        ConnectionFactory.fullConnect(layer, -0.3);

        //----------------------------------------------

        layer = this.getLayerAt(6);

        neuron = new IACNeuron(); // Art     Jets  40's  J.H.  Single     Pusher
        layer.addNeuron(neuron);
        this.createConnection(neuron, this.getLayerAt(0).getNeuronAt(0), 0.1)// art
        this.createConnection(neuron, this.getLayerAt(1).getNeuronAt(0), 0.1)// jets
        this.createConnection(neuron, this.getLayerAt(2).getNeuronAt(2), 0.1)// 40'a
        this.createConnection(neuron, this.getLayerAt(3).getNeuronAt(0), 0.1)// J.H.
        this.createConnection(neuron, this.getLayerAt(4).getNeuronAt(0), 0.1)// Single
        this.createConnection(neuron, this.getLayerAt(5).getNeuronAt(0), 0.1)// Pusher

        this.createConnection(this.getLayerAt(0).getNeuronAt(0), neuron, 0.1)// art
        this.createConnection(this.getLayerAt(1).getNeuronAt(0), neuron, 0.1)// jets
        this.createConnection(this.getLayerAt(2).getNeuronAt(2), neuron, 0.1)// 40'a
        this.createConnection(this.getLayerAt(3).getNeuronAt(0), neuron, 0.1)// J.H.
        this.createConnection(this.getLayerAt(4).getNeuronAt(0), neuron, 0.1)// Single
        this.createConnection(this.getLayerAt(5).getNeuronAt(0), neuron, 0.1)// Pusher


        neuron = new IACNeuron(); // Rick  Sharks  30's  H.S.  Divorced   Burglar
        layer.addNeuron(neuron);
        this.createConnection(neuron, this.getLayerAt(0).getNeuronAt(1), 0.1)// Rick
        this.createConnection(neuron, this.getLayerAt(1).getNeuronAt(1), 0.1)// Sharks
        this.createConnection(neuron, this.getLayerAt(2).getNeuronAt(1), 0.1)// 30'a
        this.createConnection(neuron, this.getLayerAt(3).getNeuronAt(1), 0.1)// H.S.
        this.createConnection(neuron, this.getLayerAt(4).getNeuronAt(2), 0.1)// Divorced
        this.createConnection(neuron, this.getLayerAt(5).getNeuronAt(1), 0.1)// Burglar

        this.createConnection(this.getLayerAt(0).getNeuronAt(1), neuron, 0.1)// Rick
        this.createConnection(this.getLayerAt(1).getNeuronAt(1), neuron, 0.1)// Sharks
        this.createConnection(this.getLayerAt(2).getNeuronAt(1), neuron, 0.1)// 30'a
        this.createConnection(this.getLayerAt(3).getNeuronAt(1), neuron, 0.1)// H.S.
        this.createConnection(this.getLayerAt(4).getNeuronAt(2), neuron, 0.1)// Divorced
        this.createConnection(this.getLayerAt(5).getNeuronAt(1), neuron, 0.1)// Burglar

        neuron = new IACNeuron(); // Sam     Jets  20's  College  Single     Bookie
        layer.addNeuron(neuron);
        this.createConnection(neuron, this.getLayerAt(0).getNeuronAt(2), 0.1)// Sam
        this.createConnection(neuron, this.getLayerAt(1).getNeuronAt(0), 0.1)// Jets
        this.createConnection(neuron, this.getLayerAt(2).getNeuronAt(0), 0.1)// 20's
        this.createConnection(neuron, this.getLayerAt(3).getNeuronAt(2), 0.1)// College
        this.createConnection(neuron, this.getLayerAt(4).getNeuronAt(0), 0.1)// Single
        this.createConnection(neuron, this.getLayerAt(5).getNeuronAt(2), 0.1)// Bookie

        this.createConnection(this.getLayerAt(0).getNeuronAt(2), neuron, 0.1)// Sam
        this.createConnection(this.getLayerAt(1).getNeuronAt(0), neuron, 0.1)// Jets
        this.createConnection(this.getLayerAt(2).getNeuronAt(0), neuron, 0.1)// 20's
        this.createConnection(this.getLayerAt(3).getNeuronAt(2), neuron, 0.1)// College
        this.createConnection(this.getLayerAt(4).getNeuronAt(0), neuron, 0.1)// Single
        this.createConnection(this.getLayerAt(5).getNeuronAt(2), neuron, 0.1)// Bookie

        neuron = new IACNeuron(); // Ralph  Jets  30's  J.H.  Single     Pusher
        layer.addNeuron(neuron);
        this.createConnection(neuron, this.getLayerAt(0).getNeuronAt(3), 0.1)// Ralph
        this.createConnection(neuron, this.getLayerAt(1).getNeuronAt(0), 0.1)// Jets
        this.createConnection(neuron, this.getLayerAt(2).getNeuronAt(1), 0.1)// 30's
        this.createConnection(neuron, this.getLayerAt(3).getNeuronAt(0), 0.1)// J.H.
        this.createConnection(neuron, this.getLayerAt(4).getNeuronAt(0), 0.1)// Single
        this.createConnection(neuron, this.getLayerAt(5).getNeuronAt(0), 0.1)// Pusher

        this.createConnection(this.getLayerAt(0).getNeuronAt(3), neuron, 0.1)// Ralph
        this.createConnection(this.getLayerAt(1).getNeuronAt(0), neuron, 0.1)// Jets
        this.createConnection(this.getLayerAt(2).getNeuronAt(1), neuron, 0.1)// 30's
        this.createConnection(this.getLayerAt(3).getNeuronAt(0), neuron, 0.1)// J.H.
        this.createConnection(this.getLayerAt(4).getNeuronAt(0), neuron, 0.1)// Single
        this.createConnection(this.getLayerAt(5).getNeuronAt(0), neuron, 0.1)// Pusher

        neuron = new IACNeuron(); // Lance  Jets  20's  J.H.  Married    Burglar
        layer.addNeuron(neuron);
        this.createConnection(neuron, this.getLayerAt(0).getNeuronAt(4), 0.1)// Lance
        this.createConnection(neuron, this.getLayerAt(1).getNeuronAt(0), 0.1)// Jets
        this.createConnection(neuron, this.getLayerAt(2).getNeuronAt(0), 0.1)// 20's
        this.createConnection(neuron, this.getLayerAt(3).getNeuronAt(0), 0.1)// J.H.
        this.createConnection(neuron, this.getLayerAt(4).getNeuronAt(1), 0.1)// Married
View Full Code Here

   * Sets default input and output neurons for network (first layer as input,
   * last as output)
   */
  public static void setDefaultIO(NeuralNetwork nnet) {
                ArrayList<Neuron> inputNeurons = new ArrayList<Neuron>();
                Layer firstLayer = (Layer) nnet.getLayers().get(0);
                for (Neuron neuron : firstLayer.getNeurons() ) {
                    if (!(neuron instanceof BiasNeuron)) {  // dont set input to bias neurons
                        inputNeurons.add(neuron);
                    }
                }

View Full Code Here

    // init neuron settings for input layer
    NeuronProperties inputNeuronProperties = new NeuronProperties();
       inputNeuronProperties.setProperty("transferFunction", TransferFunctionType.LINEAR);

    // create input layer
    Layer inputLayer = LayerFactory.createLayer(inputNeuronsCount, inputNeuronProperties);
    this.addLayer(inputLayer);

    NeuronProperties outputNeuronProperties = new NeuronProperties();
    outputNeuronProperties.setProperty("neuronType", ThresholdNeuron.class);
    outputNeuronProperties.setProperty("thresh", new Double(Math.abs(Math.random())));
    outputNeuronProperties.setProperty("transferFunction", transferFunctionType);
    // for sigmoid and tanh transfer functions set slope propery
    outputNeuronProperties.setProperty("transferFunction.slope", new Double(1));

    // createLayer output layer
    Layer outputLayer = LayerFactory.createLayer(outputNeuronsCount, outputNeuronProperties);
    this.addLayer(outputLayer);

    // create full conectivity between input and output layer
    ConnectionFactory.fullConnect(inputLayer, outputLayer);
View Full Code Here

    // set network type
    this.setNetworkType(NeuralNetworkType.HOPFIELD);

    // createLayer neurons in layer
    Layer layer = LayerFactory.createLayer(neuronsCount, neuronProperties);

    // createLayer full connectivity in layer
    ConnectionFactory.fullConnect(layer, 0.1);

    // add layer to network
View Full Code Here

                                                    );
    // set network type
    this.setNetworkType(NeuralNetworkType.KOHONEN);

    // createLayer input layer
    Layer inLayer = LayerFactory.createLayer(inputNeuronsCount,
        inputNeuronProperties);
    this.addLayer(inLayer);

    // createLayer map layer
    Layer mapLayer = LayerFactory.createLayer(outputNeuronsCount,
        outputNeuronProperties);
    this.addLayer(mapLayer);

    // createLayer full connectivity between input and output layer
    ConnectionFactory.fullConnect(inLayer, mapLayer);
View Full Code Here

* @author Zoran Sevarac <sevarac@gmail.com>
*/
public class LayerFactory {

  public static Layer createLayer(int neuronsCount, NeuronProperties neuronProperties) {
    Layer layer = new Layer(neuronsCount, neuronProperties);
          return layer;
  }
View Full Code Here

  }

  public static Layer createLayer(int neuronsCount, TransferFunctionType transferFunctionType) {
    NeuronProperties neuronProperties = new NeuronProperties();
    neuronProperties.setProperty("transferFunction", transferFunctionType);
    Layer layer = createLayer(neuronsCount, neuronProperties);
    return layer;
  }
View Full Code Here

    Layer layer = createLayer(neuronsCount, neuronProperties);
    return layer;
  }

  public static Layer createLayer(Vector<NeuronProperties> neuronPropertiesVector) {
    Layer layer = new Layer();
   
    for(NeuronProperties neuronProperties : neuronPropertiesVector) {
      Neuron neuron = NeuronFactory.createNeuron(neuronProperties);
      layer.addNeuron(neuron);
    }
   
    return layer;
  }
View Full Code Here

TOP

Related Classes of org.neuroph.core.Layer

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.