Пример #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 RbfNetwork architecture with specified number of neurons in input
        /// layer, output layer and transfer function 
        /// </summary>
        /// <param name="inputNeuronsCount">number of neurons in input layer</param>
        /// <param name="rbfNeuronsCount">number of neurons in rbf layer</param>
        /// <param name="outputNeuronsCount">number of neurons in output layer</param>
        private void CreateNetwork(int inputNeuronsCount, int rbfNeuronsCount,
            int outputNeuronsCount)
        {
            // init neuron settings for this network
            NeuronProperties rbfNeuronProperties = new NeuronProperties();
            rbfNeuronProperties.SetProperty("weightsFunction", typeof(Diference));
            rbfNeuronProperties.SetProperty("summingFunction", typeof(Intensity));
            rbfNeuronProperties.SetProperty("transferFunction", typeof(Gaussian));

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

            // create input layer
            Layer inputLayer = LayerFactory.createLayer(inputNeuronsCount, TransferFunctionType.LINEAR);
            this.AddLayer(inputLayer);

            // create rbf layer
            Layer rbfLayer = LayerFactory.createLayer(rbfNeuronsCount, rbfNeuronProperties);
            this.AddLayer(rbfLayer);

            // create output layer
            Layer outputLayer = LayerFactory.createLayer(outputNeuronsCount, TransferFunctionType.LINEAR);
            this.AddLayer(outputLayer);

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

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

            // set appropriate learning rule for this network
            this.LearningRule = new LMS(this);
        }
Пример #3
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);
        }
Пример #4
0
        /// <summary>
        /// Creates Instar 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
            this.NetworkType = NeuralNetworkType.INSTAR;

            // init neuron settings for this type of network
            NeuronProperties neuronProperties = new NeuronProperties();
            neuronProperties.SetProperty("transferFunction", TransferFunctionType.STEP);

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

            // createLayer output layer
            neuronProperties.SetProperty("transferFunction", TransferFunctionType.STEP);
            Layer outputLayer = LayerFactory.createLayer(1, 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.SetDefaultIO(this);

            // set appropriate learning rule for this network
            this.LearningRule = new InstarLearning(this);
        }
Пример #5
0
        /// <summary>
        /// Creates Kohonen network architecture with specified number of neurons in
        /// input and map layer 
        /// </summary>
        /// <param name="inputNeuronsCount">number of neurons in input layer</param>
        /// <param name="outputNeuronsCount">number of neurons in output layer</param>
        private void CreateNetwork(int inputNeuronsCount, int outputNeuronsCount)
        {
            // specify input neuron properties (use default: weighted sum input with
            // linear transfer)
            NeuronProperties inputNeuronProperties = new NeuronProperties();

            // specify map neuron properties
            NeuronProperties outputNeuronProperties = new NeuronProperties();
            outputNeuronProperties.SetProperty("weightsFunction", typeof(Diference));
            outputNeuronProperties.SetProperty("summingFunction", typeof(Intensity));
            outputNeuronProperties.SetProperty("transferFunction", typeof(Linear));

            // set network type
            this.NetworkType = 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);

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

            this.LearningRule = new KohonenLearning(this);
        }
Пример #6
0
        /// <summary>
        /// Creates new MultiLayerPerceptron with specified number of neurons in layers 
        /// </summary>
        /// <param name="neuronsInLayers">collection of neuron number in layers</param>
        public MultiLayerPerceptron(IList<int> neuronsInLayers)
        {
            // init neuron settings
            NeuronProperties neuronProperties = new NeuronProperties();
            neuronProperties.SetProperty("useBias", true);
            neuronProperties.SetProperty("transferFunction", TransferFunctionType.SIGMOID);

            this.CreateNetwork(neuronsInLayers, neuronProperties);
        }
Пример #7
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);
            neuronProperties.SetProperty("transferFunction.yHigh", 1);
            neuronProperties.SetProperty("transferFunction.yLow", 0);

            this.CreateNetwork(neuronsCount, neuronProperties);
        }
Пример #8
0
        public MultiLayerPerceptron(TransferFunctionType transferFunctionType, params int[] neuronsInLayers)
        {
            // init neuron settings
            NeuronProperties neuronProperties = new NeuronProperties();
            neuronProperties.SetProperty("useBias", true);
            neuronProperties.SetProperty("transferFunction", transferFunctionType);
            neuronProperties.SetProperty("inputFunction", typeof(WeightedSum));

            IList<int> neuronsInLayersVector = new List<int>();
            for (int i = 0; i < neuronsInLayers.Length; i++)
                neuronsInLayersVector.Add(neuronsInLayers[i]);

            this.CreateNetwork(neuronsInLayersVector, 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);
            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.SetDefaultIO(this);

            // set appropriate learning rule for this network
            this.LearningRule = new SupervisedHebbianLearning(this);
        }
Пример #10
0
        /// <summary>
        /// Creates perceptron architecture with specified number of neurons in input
        /// and output layer, specified transfer function
        /// </summary>
        /// <param name="inputNeuronsCount">number of neurons in input layer</param>
        /// <param name="outputNeuronsCount">number of neurons in output layer</param>
        /// <param name="transferFunctionType">neuron transfer function type</param>
        private void CreateNetwork(int inputNeuronsCount, int outputNeuronsCount, TransferFunctionType transferFunctionType)
        {
            // set network type
            this.NetworkType = NeuralNetworkType.PERCEPTRON;

            // 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", typeof(ThresholdNeuron));
            outputNeuronProperties.SetProperty("thresh", Math.Abs(ThreadSafeRandom.NextDouble()));
            outputNeuronProperties.SetProperty("transferFunction", transferFunctionType);
            // for sigmoid and tanh transfer functions set slope propery
            outputNeuronProperties.SetProperty("transferFunction.slope", 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);

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

            this.LearningRule = new BinaryDeltaRule();
        }
Пример #11
0
 public static Layer createLayer(int neuronsCount, TransferFunctionType transferFunctionType)
 {
     NeuronProperties neuronProperties = new NeuronProperties();
     neuronProperties.SetProperty("transferFunction", transferFunctionType);
     Layer layer = createLayer(neuronsCount, neuronProperties);
     return layer;
 }
        /// <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);
            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.SetDefaultIO(this);

            // set appropriate learning rule for this network
            this.LearningRule = new UnsupervisedHebbianLearning(this);
            //this.setLearningRule(new OjaLearning(this));
        }