示例#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();
        }
示例#2
0
        /// <summary>
        /// Creates BAM network architecture
        /// </summary>
        /// <param name="inputNeuronsCount">
        ///            number of neurons in input layer </param>
        /// <param name="outputNeuronsCount">
        ///            number of neurons in output layer </param>
        /// <param name="neuronProperties">
        ///            neuron properties </param>
        private void createNetwork(int inputNeuronsCount, int outputNeuronsCount, NeuronProperties neuronProperties)
        {
            // set network type
            this.NetworkType = NeuralNetworkType.BAM;

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

            // add input layer to network
            this.addLayer(inputLayer);

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

            // add output layer to network
            this.addLayer(outputLayer);

            // create full connectivity from in to out layer
            ConnectionFactory.fullConnect(inputLayer, outputLayer);
            // create full connectivity from out to in layer
            ConnectionFactory.fullConnect(outputLayer, inputLayer);

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

            // set Hebbian learning rule for this network
            this.LearningRule = new BinaryHebbianLearning();
        }
示例#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));
        }
示例#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;
        }
        /// <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();
        }
示例#6
0
        /// <summary>
        /// Creates Hopfield network architecture
        /// </summary>
        /// <param name="neuronsCount">
        ///            neurons number in Hopfied network </param>
        /// <param name="neuronProperties">
        ///            neuron properties </param>
        private void createNetwork(int neuronsCount, NeuronProperties neuronProperties)
        {
            // set network type
            this.NetworkType = 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
            this.addLayer(layer);

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

            // set Hopfield learning rule for this network
            //this.setLearningRule(new HopfieldLearning(this));
            this.LearningRule = new BinaryHebbianLearning();
        }
示例#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();
        }
示例#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();
        }
示例#9
0
        /// <summary>
        /// Creates connections with shared weights between two feature maps
        /// Assumes that toMap is from Pooling layer.
        /// <p/>
        /// In this implementation, there is no overlapping between kernel positions.
        /// </summary>
        /// <param name="fromMap"> source feature map </param>
        /// <param name="toMap">   destination feature map </param>
        public override void connectMaps(FeatureMapLayer fromMap, FeatureMapLayer toMap)
        {
            int    kernelWidth  = kernel.Width;
            int    kernelHeight = kernel.Height;
            Weight weight       = new Weight(1);

            for (int x = 0; x < fromMap.Width - kernelWidth + 1; x += kernelWidth)             // < da li step treba da je kernel
            {
                for (int y = 0; y < fromMap.Height - kernelHeight + 1; y += kernelHeight)
                {
                    Neuron toNeuron = toMap.getNeuronAt(x / kernelWidth, y / kernelHeight);
                    for (int dy = 0; dy < kernelHeight; dy++)
                    {
                        for (int dx = 0; dx < kernelWidth; dx++)
                        {
                            int    fromX      = x + dx;
                            int    fromY      = y + dy;
                            Neuron fromNeuron = fromMap.getNeuronAt(fromX, fromY);
                            ConnectionFactory.createConnection(fromNeuron, toNeuron, weight);
                        }
                    }
                }
            }
        }