Example #1
0
        /// <summary>
        /// Creates Outstar architecture with specified number of neurons in
        /// output layer
        /// </summary>
        /// <param name="outputNeuronsCount">
        ///            number of neurons in output layer </param>
        private void createNetwork(int outputNeuronsCount)
        {
            // set network type
            this.NetworkType = NeuralNetworkType.OUTSTAR;

            // init neuron settings for this type of network
            NeuronProperties neuronProperties = new NeuronProperties();

            neuronProperties.setProperty("transferFunction", TransferFunctionType.Step.ToString());

            // create input layer
            Layer inputLayer = LayerFactory.createLayer(1, neuronProperties);

            this.addLayer(inputLayer);

            // createLayer output layer
            neuronProperties.setProperty("transferFunction", TransferFunctionType.Ramp.ToString());
            Layer outputLayer = LayerFactory.createLayer(outputNeuronsCount, neuronProperties);

            this.addLayer(outputLayer);

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

            // set input and output cells for this network
            NeuralNetworkFactory.DefaultIO = this;

            // set outstar learning rule for this network
            this.LearningRule = new OutstarLearning();
        }
Example #2
0
 static PoolingLayer()
 {
     DEFAULT_NEURON_PROP.setProperty("useBias", true);
     DEFAULT_NEURON_PROP.setProperty("transferFunction", (util.TransferFunctionType.Tanh.ToString()));
     //    DEFAULT_NEURON_PROP.setProperty("transferFunction", Ramp.class);
     DEFAULT_NEURON_PROP.setProperty("inputFunction", typeof(Max));
 }
Example #3
0
        /// <summary>
        /// Creates an instance of Unsuervised Hebian net with specified number
        /// of neurons in input layer and output layer, and transfer function
        /// </summary>
        /// <param name="inputNeuronsNum">
        ///            number of neurons in input layer </param>
        /// <param name="outputNeuronsNum">
        ///            number of neurons in output layer </param>
        /// <param name="transferFunctionType">
        ///            transfer function type </param>
        private void createNetwork(int inputNeuronsNum, int outputNeuronsNum, TransferFunctionType transferFunctionType)
        {
            // init neuron properties
            NeuronProperties neuronProperties = new NeuronProperties();

            //		neuronProperties.setProperty("bias", new Double(-Math
            //				.abs(Math.random() - 0.5))); // Hebbian network cann not work
            // without bias
            neuronProperties.setProperty("transferFunction", transferFunctionType.ToString());
            neuronProperties.setProperty("transferFunction.slope", 1);

            // set network type code
            this.NetworkType = NeuralNetworkType.UNSUPERVISED_HEBBIAN_NET;

            // createLayer input layer
            Layer inputLayer = LayerFactory.createLayer(inputNeuronsNum, neuronProperties);

            this.addLayer(inputLayer);

            // createLayer output layer
            Layer outputLayer = LayerFactory.createLayer(outputNeuronsNum, neuronProperties);

            this.addLayer(outputLayer);

            // createLayer full conectivity between input and output layer
            ConnectionFactory.fullConnect(inputLayer, outputLayer);

            // set input and output cells for this network
            NeuralNetworkFactory.DefaultIO = this;

            // set appropriate learning rule for this network
            this.LearningRule = new UnsupervisedHebbianLearning();
            //this.setLearningRule(new OjaLearning(this));
        }
Example #4
0
        /// <summary>
        /// Creates MaxNet network architecture
        /// </summary>
        /// <param name="neuronNum">
        ///            neuron number in network </param>
        /// <param name="neuronProperties">
        ///            neuron properties </param>
        private void createNetwork(int neuronsCount)
        {
            // set network type
            this.NetworkType = NeuralNetworkType.MAXNET;

            // createLayer input layer in layer
            Layer inputLayer = LayerFactory.createLayer(neuronsCount, new NeuronProperties());

            this.addLayer(inputLayer);

            // createLayer properties for neurons in output layer
            NeuronProperties neuronProperties = new NeuronProperties();

            neuronProperties.setProperty("neuronType", typeof(CompetitiveNeuron));
            neuronProperties.setProperty("transferFunction", TransferFunctionType.Ramp.ToString());

            // createLayer full connectivity in competitive layer
            CompetitiveLayer competitiveLayer = new CompetitiveLayer(neuronsCount, neuronProperties);

            // add competitive layer to network
            this.addLayer(competitiveLayer);

            double competitiveWeight = -(1 / (double)neuronsCount);

            // createLayer full connectivity within competitive layer
            ConnectionFactory.fullConnect(competitiveLayer, competitiveWeight, 1);

            // createLayer forward connectivity from input to competitive layer
            ConnectionFactory.forwardConnect(inputLayer, competitiveLayer, 1);

            // set input and output cells for this network
            NeuralNetworkFactory.DefaultIO = this;
        }
Example #5
0
        /// <summary>
        /// Creates new Hopfield network with specified neuron number
        /// </summary>
        /// <param name="neuronsCount">
        ///            neurons number in Hopfied network </param>
        public Hopfield(int neuronsCount)
        {
            // init neuron settings for hopfield network
            NeuronProperties neuronProperties = new NeuronProperties();

            neuronProperties.setProperty("neuronType", typeof(InputOutputNeuron));
            neuronProperties.setProperty("bias", 0);
            neuronProperties.setProperty("transferFunction", TransferFunctionType.Step.ToString());
            neuronProperties.setProperty("transferFunction.yHigh", 1);
            neuronProperties.setProperty("transferFunction.yLow", 0);

            this.createNetwork(neuronsCount, neuronProperties);
        }
        /// <summary>
        /// Creates an instance of Supervised Hebbian Network with specified number
        /// of neurons in input layer, output layer and transfer function
        /// </summary>
        /// <param name="inputNeuronsNum">
        ///            number of neurons in input layer </param>
        /// <param name="outputNeuronsNum">
        ///            number of neurons in output layer </param>
        /// <param name="transferFunctionType">
        ///            transfer function type </param>
        private void createNetwork(int inputNeuronsNum, int outputNeuronsNum, TransferFunctionType transferFunctionType)
        {
            // init neuron properties
            NeuronProperties neuronProperties = new NeuronProperties();

            neuronProperties.setProperty("transferFunction", transferFunctionType.ToString());
            neuronProperties.setProperty("transferFunction.slope", 1);
            neuronProperties.setProperty("transferFunction.yHigh", 1);
            neuronProperties.setProperty("transferFunction.xHigh", 1);
            neuronProperties.setProperty("transferFunction.yLow", -1);
            neuronProperties.setProperty("transferFunction.xLow", -1);

            // set network type code
            this.NetworkType = NeuralNetworkType.SUPERVISED_HEBBIAN_NET;

            // createLayer input layer
            Layer inputLayer = LayerFactory.createLayer(inputNeuronsNum, neuronProperties);

            this.addLayer(inputLayer);

            // createLayer output layer
            Layer outputLayer = LayerFactory.createLayer(outputNeuronsNum, neuronProperties);

            this.addLayer(outputLayer);

            // createLayer full conectivity between input and output layer
            ConnectionFactory.fullConnect(inputLayer, outputLayer);

            // set input and output cells for this network
            NeuralNetworkFactory.DefaultIO = this;

            // set appropriate learning rule for this network
            this.LearningRule = new SupervisedHebbianLearning();
        }
Example #7
0
        // three layers: input, hidden, output
        // as mlp add context layer
        // jordan  connect output of output  layer to input of context layer
        // output of context to input of hidden layer



        private void createNetwork(int inputNeuronsCount, int hiddenNeuronsCount, int contextNeuronsCount, int outputNeuronsCount)
        {
            // create input layer
            InputLayer inputLayer = new InputLayer(inputNeuronsCount);

            inputLayer.addNeuron(new BiasNeuron());
            addLayer(inputLayer);

            NeuronProperties neuronProperties = new NeuronProperties();

            // neuronProperties.setProperty("useBias", true);
            neuronProperties.setProperty("transferFunction", TransferFunctionType.Sigmoid.ToString());             // use linear or logitic function! (TR-8604.pdf)

            Layer hiddenLayer = new Layer(hiddenNeuronsCount, neuronProperties);

            hiddenLayer.addNeuron(new BiasNeuron());
            addLayer(hiddenLayer);

            ConnectionFactory.fullConnect(inputLayer, hiddenLayer);

            Layer contextLayer = new Layer(contextNeuronsCount, neuronProperties);

            addLayer(contextLayer);                             // we might also need bias for context neurons?

            Layer outputLayer = new Layer(outputNeuronsCount, neuronProperties);

            addLayer(outputLayer);

            ConnectionFactory.fullConnect(hiddenLayer, outputLayer);

            ConnectionFactory.fullConnect(outputLayer, contextLayer);
            ConnectionFactory.fullConnect(contextLayer, hiddenLayer);


            // set input and output cells for network
            NeuralNetworkFactory.DefaultIO = this;

            // set learnng rule
            this.LearningRule = new BackPropagation();
        }
Example #8
0
        /// <summary>
        /// Creates adaline network architecture with specified number of input neurons
        /// </summary>
        /// <param name="inputNeuronsCount">
        ///              number of neurons in input layer </param>
        private void createNetwork(int inputNeuronsCount)
        {
            // set network type code
            this.NetworkType = NeuralNetworkType.ADALINE;

            // create input layer neuron settings for this network
            NeuronProperties inNeuronProperties = new NeuronProperties();

            inNeuronProperties.setProperty("transferFunction", TransferFunctionType.Linear.ToString());

            // createLayer input layer with specified number of neurons
            Layer inputLayer = LayerFactory.createLayer(inputNeuronsCount, inNeuronProperties);

            inputLayer.addNeuron(new BiasNeuron());                             // add bias neuron (always 1, and it will act as bias input for output neuron)
            this.addLayer(inputLayer);

            // create output layer neuron settings for this network
            NeuronProperties outNeuronProperties = new NeuronProperties();

            outNeuronProperties.setProperty("transferFunction", TransferFunctionType.Ramp.ToString());
            outNeuronProperties.setProperty("transferFunction.slope", 1);
            outNeuronProperties.setProperty("transferFunction.yHigh", 1);
            outNeuronProperties.setProperty("transferFunction.xHigh", 1);
            outNeuronProperties.setProperty("transferFunction.yLow", -1);
            outNeuronProperties.setProperty("transferFunction.xLow", -1);

            // createLayer output layer (only one neuron)
            Layer outputLayer = LayerFactory.createLayer(1, outNeuronProperties);

            this.addLayer(outputLayer);

            // createLayer full conectivity between input and output layer
            ConnectionFactory.fullConnect(inputLayer, outputLayer);

            // set input and output cells for network
            NeuralNetworkFactory.DefaultIO = this;

            // set LMS learning rule for this network
            this.LearningRule = new LMS();
        }
        public virtual void createDemoNetwork()
        {
            int productsCount = 20;
            int typesCount    = 3;
            int brandsCount   = 3;
            int priceCount    = 3;
            int promoCount    = 3;

            this.NetworkType = NeuralNetworkType.RECOMMENDER;
            //this.getLayers().clear();
            // init neuron settings for this type of network
            NeuronProperties neuronProperties = new NeuronProperties();

            neuronProperties.setProperty("transferFunction", TransferFunctionType.Ramp.ToString());
            // for sigmoid and tanh transfer functions
            neuronProperties.setProperty("transferFunction.slope", 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();
            createBrandConnections();
            createPriceConnections();
            createPromoConnections();


            // create reccurent self connections in output layer
            foreach (Neuron neuron in this.getLayerAt(outputLayerIdx).Neurons)
            {
                neuron.addInputConnection(neuron, 1);
            }

            // set input and output cells for this network
            NeuralNetworkFactory.DefaultIO = this;

            // dont learn the self connections
            // moze cak i posle svakog prolaza da se primenjuje hebbianovo pravilo a ne samo nakon kupovine
            // napravi vise varijanti
            // ako kupuje onda moze da se primenjje winner takes all hebbian learning
            this.LearningRule = new UnsupervisedHebbianLearning();
        }
Example #10
0
 static InputMapsLayer()
 {
     DEFAULT_NEURON_PROP.setProperty("neuronType", typeof(InputNeuron));
     DEFAULT_NEURON_PROP.setProperty("transferFunction", util.TransferFunctionType.Linear.ToString());
 }