Пример #1
0
        /// <summary>
        /// Creates MaxNet network architecture
        /// </summary>
        /// <param name="neuronsCount">neuron number in network</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);

            // 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.SetDefaultIO(this);
        }
Пример #2
0
        /// <summary>
        /// Creates Competitive network architecture
        /// </summary>
        /// <param name="inputNeuronsCount">input neurons number</param>
        /// <param name="outputNeuronsCount">neuron properties</param>
        private void CreateNetwork(int inputNeuronsCount, int outputNeuronsCount)
        {
            // set network type
            this.NetworkType = NeuralNetworkType.COMPETITIVE;

            // createLayer input layer
            Layer inputLayer = LayerFactory.createLayer(inputNeuronsCount, new NeuronProperties());
            this.AddLayer(inputLayer);

            // createLayer properties for neurons in output layer
            NeuronProperties neuronProperties = new NeuronProperties();
            neuronProperties.SetProperty("neuronType", typeof(CompetitiveNeuron));
            neuronProperties.SetProperty("weightsFunction", typeof(WeightedInput));
            neuronProperties.SetProperty("summingFunction", typeof(Sum));
            neuronProperties.SetProperty("transferFunction", TransferFunctionType.RAMP);

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

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

            double competitiveWeight = -(1 / (double)outputNeuronsCount);
            // createLayer full connectivity within competitive layer
            ConnectionFactory.FullConnect(competitiveLayer, competitiveWeight, 1);

            // createLayer full connectivity from input to competitive layer
            ConnectionFactory.FullConnect(inputLayer, competitiveLayer);

            // set input and output cells for this network
            NeuralNetworkFactory.SetDefaultIO(this);

            this.LearningRule = new CompetitiveLearning(this);
        }