Пример #1
0
 /// <summary>
 /// Creates an instance of Layer with the specified number of neurons with
 /// specified neuron properties
 /// </summary>
 /// <param name="neuronsCount"> number of neurons in layer </param>
 /// <param name="neuronProperties"> properties of neurons in layer </param>
 public Layer(int neuronsCount, NeuronProperties neuronProperties) : this(neuronsCount) {
     for (int i = 0; i < neuronsCount; i++)
     {
         Neuron neuron = NeuronFactory.createNeuron(neuronProperties);
         this.addNeuron(neuron);
     }
 }
Пример #2
0
 private void createFeatureMaps(int mapCount, Dimension2D mapDimensions, NeuronProperties neuronProperties)
 {
     for (int i = 0; i < mapCount; i++)
     {
         addFeatureMap(new FeatureMapLayer(mapDimensions, neuronProperties));
     }
 }
Пример #3
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(typeof(Neuron), typeof(Difference), typeof(Linear));             // transfer function -  input function -  neuron type

            // 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.DefaultIO = this;

            this.LearningRule = new KohonenLearning();
        }
Пример #4
0
        /// <summary>
        /// Creates MultiLayerPerceptron Network architecture - fully connected
        /// feed forward with specified number of neurons in each layer
        /// </summary>
        /// <param name="neuronsInLayers">  collection of neuron numbers in getLayersIterator </param>
        /// <param name="neuronProperties"> neuron properties </param>
        private void createNetwork(List <int> neuronsInLayers, NeuronProperties neuronProperties)
        {
            // set network type
            this.NetworkType = NeuralNetworkType.MULTI_LAYER_PERCEPTRON;

            // create input layer
            NeuronProperties inputNeuronProperties = new NeuronProperties(typeof(InputNeuron), typeof(Linear));
            Layer            layer = LayerFactory.createLayer(neuronsInLayers[0], inputNeuronProperties);

            bool useBias = true;             // use bias neurons by default

            if (neuronProperties.hasProperty("useBias"))
            {
                useBias = (bool)neuronProperties.getProperty("useBias");
            }

            if (useBias)
            {
                layer.addNeuron(new BiasNeuron());
            }

            this.addLayer(layer);

            // create layers
            Layer prevLayer = layer;

            //for(Integer neuronsNum : neuronsInLayers)
            for (int layerIdx = 1; layerIdx < neuronsInLayers.Count; layerIdx++)
            {
                int neuronsNum = neuronsInLayers[layerIdx];
                // createLayer layer
                layer = LayerFactory.createLayer(neuronsNum, neuronProperties);

                if (useBias && (layerIdx < (neuronsInLayers.Count - 1)))
                {
                    layer.addNeuron(new BiasNeuron());
                }

                // add created layer to network
                this.addLayer(layer);
                // createLayer full connectivity between previous and this layer
                if (prevLayer != null)
                {
                    ConnectionFactory.fullConnect(prevLayer, layer);
                }

                prevLayer = layer;
            }

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

            // set learnng rule
            //        this.setLearningRule(new BackPropagation());
            this.LearningRule = new MomentumBackpropagation();
            // this.setLearningRule(new DynamicBackPropagation());

            this.randomizeWeights(new RangeRandomizer(-0.7, 0.7));
        }
Пример #5
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(List <int> neuronsInLayers)
        {
            // init neuron settings
            NeuronProperties neuronProperties = new NeuronProperties();

            neuronProperties.setProperty("useBias", true);
            neuronProperties.setProperty("transferFunction", TransferFunctionType.Sigmoid.ToString());

            this.createNetwork(neuronsInLayers, neuronProperties);
        }
Пример #6
0
        /// <summary>
        /// Creates convolutional layer with specified kernel, appropriate map
        /// dimensions in regard to previous layer (fromLayer param) and specified
        /// number of feature maps with default neuron settings for convolutional
        /// layer.
        /// </summary>
        /// <param name="fromLayer"> previous layer, which will be connected to this layer </param>
        /// <param name="kernel"> kernel for all feature maps </param>
        /// <param name="numberOfMaps"> number of feature maps to create in this layer </param>
        /// <param name="transferFunction"> neuron's transfer function to use </param>
        public ConvolutionalLayer(FeatureMapsLayer fromLayer, Dimension2D kernelDimension, int numberOfMaps, Type transferFunction)
        {
            Dimension2D fromDimension = fromLayer.MapDimensions;

            int mapWidth  = fromDimension.Width - kernelDimension.Width + 1;
            int mapHeight = fromDimension.Height - kernelDimension.Height + 1;

            this.mapDimensions = new Dimension2D(mapWidth, mapHeight);

            NeuronProperties neuronProp = new NeuronProperties(typeof(Neuron), transferFunction);

            createFeatureMaps(numberOfMaps, this.mapDimensions, kernelDimension, neuronProp);
        }
Пример #7
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.ToString());

            // 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(new Random(1).NextDouble()));
            outputNeuronProperties.setProperty("transferFunction", transferFunctionType.ToString());
            // 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.DefaultIO = this;

            this.LearningRule = new BinaryDeltaRule();
            // set appropriate learning rule for this network
            //		if (transferFunctionType == TransferFunctionType.STEP) {
            //			this.setLearningRule(new BinaryDeltaRule(this));
            //		} else if (transferFunctionType == TransferFunctionType.SIGMOID) {
            //			this.setLearningRule(new SigmoidDeltaRule(this));
            //		} else if (transferFunctionType == TransferFunctionType.TANH) {
            //			this.setLearningRule(new SigmoidDeltaRule(this));
            //		} else {
            //			this.setLearningRule(new PerceptronLearning(this));
            //		}
        }
Пример #8
0
        public MultiLayerPerceptron(params int[] neuronsInLayers)
        {
            // init neuron settings
            NeuronProperties neuronProperties = new NeuronProperties();

            neuronProperties.setProperty("useBias", true);
            neuronProperties.setProperty("transferFunction", TransferFunctionType.Sigmoid.ToString());
            neuronProperties.setProperty("inputFunction", typeof(WeightedSum));

            List <int> neuronsInLayersVector = new List <int>();

            for (int i = 0; i < neuronsInLayers.Length; i++)
            {
                neuronsInLayersVector.Add(Convert.ToInt32(neuronsInLayers[i]));
            }

            this.createNetwork(neuronsInLayersVector, neuronProperties);
        }
Пример #9
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("inputFunction", typeof(Difference));
            rbfNeuronProperties.setProperty("transferFunction", util.TransferFunctionType.Gaussian.ToString());

            // 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.DefaultIO = this;

            // set appropriate learning rule for this network
            this.LearningRule = new RBFLearning();
        }
Пример #10
0
        public Form1()
        {
            InitializeComponent();
            brain = new Brain();

            NeuronProperties np = new NeuronProperties(brain.GetNeuron());

            np.ShowDialog();

            brain.DefaultNeuron.Logic     = new NeuronLogic(NeuronLogic.Algorithm.analog);
            brain.DefaultNeuron.min       = -256;
            brain.DefaultNeuron.max       = 256;
            brain.DefaultNeuron.threshold = 0;

            Neuron n1 = brain.GetNeuron("n1");

            n1.Logic     = new Oscillator(1000);
            n1.threshold = 0;

#if asdfasdf
            Neuron  n2 = brain.GetNeuron("n2");
            Synapse s1 = brain.GetSynapse("s1");
            Neuron  n3 = brain.GetNeuron("n3");
            Neuron  n4 = brain.GetNeuron("n4");
            Synapse s2 = brain.GetSynapse("s2");

            // try and use just the + operator alone...
            // fails ( ie, expression with no meaning )
//			n2 + s2 + n1 + s1 + n2;

            // manually link with external synapse...
            //n2 += s1 += n1 += s2 += n2;

            // automatically pull a synapse to link these
            n2 += n1 += n2;

            LevelLock l1 = new LevelLock(brain);
            FlipFlop  f1 = new FlipFlop(brain);

            f1 += n3;
            n4 += f1;

            //n3.threshold = -50;

            n3.Log();
            n4.Log();

            n3.Logic = new NeuronLogic(NeuronLogic.Algorithm.digital);
#endif

            while (true)
            {
                brain.cycle++;
                n1.Log();

#if asdfasdf
                n3.Log();
                n4.Log();
                f1.Log();

                //n3.threshold = -50;
                if (n3.threshold < 0)
                {
                    n3.threshold = 50;
                }
                else
                {
                    n3.threshold = -50;
                }
#endif
            }
#if asdfasdf
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);

            n3.threshold = 50;
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            n3.threshold = -50;
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);
            brain.cycle++;
            Console.WriteLine("N3 = " + (int)n3);
            Console.WriteLine("N4 = " + (int)n4);


            for (int xx = 0; xx < 100; xx++)
            {
                brain.cycle = xx;
                Console.WriteLine("output n1 = " + (int)n1);
                Console.WriteLine("output n2 = " + (int)n2);
            }


            Console.WriteLine("output n1 = " + (int)n1);
            Console.WriteLine("output n2 = " + (int)n2);
#endif

            //Point[] atest = new Point[256];
            //atest[500] = new Point( 10, 10 );
        }
Пример #11
0
 /// <summary>
 /// Creates new MultiLayerPerceptron net with specified number neurons in
 /// getLayersIterator
 /// </summary>
 /// <param name="neuronsInLayers">  collection of neuron numbers in layers </param>
 /// <param name="neuronProperties"> neuron properties </param>
 public MultiLayerPerceptron(List <int> neuronsInLayers, NeuronProperties neuronProperties)
 {
     this.createNetwork(neuronsInLayers, neuronProperties);
 }
Пример #12
0
 /// <summary>
 /// Creates new feature maps layer with specified kernel and feature maps.
 /// Also creates feature maps and neurons in feature maps;
 /// </summary>
 /// <param name="kernel">        kernel used for all feature maps in this layer </param>
 /// <param name="mapDimensions"> mapDimensions of feature maps in this layer </param>
 /// <param name="mapCount">      number of feature maps </param>
 /// <param name="neuronProp">    properties for neurons in feature maps </param>
 public FeatureMapsLayer(Dimension2D kernelDimension, Dimension2D mapDimensions, int mapCount, NeuronProperties neuronProp)
 {
     // this.kernel = kernel;
     this.mapDimensions = mapDimensions;
     this.featureMaps   = new List <FeatureMapLayer>();
     createFeatureMaps(mapCount, mapDimensions, kernelDimension, neuronProp);
 }
Пример #13
0
 /// <summary>
 /// Creates and adds specified number of feature maps to this layer
 /// </summary>
 /// <param name="mapCount">         number of feature maps to create </param>
 /// <param name="dimensions">       feature map dimensions </param>
 /// <param name="neuronProperties"> properties of neurons in feature maps </param>
 protected internal void createFeatureMaps(int mapCount, Dimension2D mapDimensions, Dimension2D kernelDimension, NeuronProperties neuronProperties)
 {
     for (int i = 0; i < mapCount; i++)
     {
         addFeatureMap(new FeatureMapLayer(mapDimensions, neuronProperties, kernelDimension));
     }
 }
Пример #14
0
        // build example network for student classification
        private void createStudentNFR(int inputNum, List <int> inputSets, int outNum, double[][] pointsSets, double[][] timeSets)
        {
            // set network type
            this.NetworkType = NeuralNetworkType.NEURO_FUZZY_REASONER;

            // createLayer input layer
            NeuronProperties neuronProperties = new NeuronProperties();
            Layer            inLayer          = LayerFactory.createLayer(inputNum, neuronProperties);

            this.addLayer(inLayer);

            // createLayer fuzzy set layer
            neuronProperties.setProperty("transferFunction", TransferFunctionType.Trapezoid.ToString());
            IEnumerator <int> e = inputSets.GetEnumerator();
            int fuzzySetsNum    = 0;

            while (e.MoveNext())
            {
                int i = e.Current;
                fuzzySetsNum = fuzzySetsNum + (int)i;
            }
            Layer setLayer = LayerFactory.createLayer(fuzzySetsNum, neuronProperties);

            this.addLayer(setLayer);

            // TODO: postavi parametre funkcija pripadnosti
            // nizove sa trning elementima iznesi van klase i prosledjuj ih kao
            // parametre
            //		Iterator<Neuron> ii = setLayer.getNeuronsIterator();
            IEnumerator <int> en;            // =setLayer.neurons();
            int c = 0;

            foreach (Neuron cell in setLayer.Neurons)
            {
                //		while (ii.hasNext()) {
                //			Neuron cell = ii.next();
                Trapezoid tf = (Trapezoid)cell.TransferFunction;

                if (c <= 3)
                {
                    tf.LeftLow   = pointsSets[c][0];
                    tf.LeftHigh  = pointsSets[c][1];
                    tf.RightLow  = pointsSets[c][3];
                    tf.RightHigh = pointsSets[c][2];
                }
                else
                {
                    tf.LeftLow   = timeSets[c - 4][0];
                    tf.LeftHigh  = timeSets[c - 4][1];
                    tf.RightLow  = timeSets[c - 4][3];
                    tf.RightHigh = timeSets[c - 4][2];
                }
                c++;
            }

            // povezi prvi i drugi sloj
            int s = 0;                         // brojac celija sloja skupova (fazifikacije)

            for (int i = 0; i < inputNum; i++) // brojac ulaznih celija
            {
                Neuron from = inLayer.getNeuronAt(i);
                int    jmax = (int)inputSets[i];
                for (int j = 0; j < jmax; j++)
                {
                    Neuron to = setLayer.getNeuronAt(s);
                    ConnectionFactory.createConnection(from, to, 1);
                    s++;
                }
            }

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

            // createLayer rules layer
            NeuronProperties ruleNeuronProperties = new NeuronProperties(typeof(Neuron), typeof(WeightedSum), typeof(Linear));

            en = inputSets.GetEnumerator();
            int fuzzyAntNum = 1;

            while (en.MoveNext())
            {
                int i = en.Current;
                fuzzyAntNum = fuzzyAntNum * (int)i;
            }
            Layer ruleLayer = LayerFactory.createLayer(fuzzyAntNum, ruleNeuronProperties);

            this.addLayer(ruleLayer);

            int scIdx = 0;                     // set cell index

            for (int i = 0; i < inputNum; i++) // brojac ulaza (grupa fuzzy
            {
                // skupova)
                int setsNum = (int)inputSets[i];

                for (int si = 0; si < setsNum; si++)                 // brojac celija fuzzy
                {
                    // skupova
                    if (i == 0)
                    {
                        Neuron from        = setLayer.getNeuronAt(si);
                        int    connPerCell = fuzzyAntNum / setsNum;
                        scIdx = si;

                        for (int k = 0; k < connPerCell; k++)                         // brojac celija
                        {
                            // hipoteza
                            Neuron to = ruleLayer.getNeuronAt(si * connPerCell + k);
                            ConnectionFactory.createConnection(from, to, 1);
                        }                 // for
                    }                     // if
                    else
                    {
                        scIdx++;
                        Neuron from        = setLayer.getNeuronAt(scIdx);
                        int    connPerCell = fuzzyAntNum / setsNum;

                        for (int k = 0; k < connPerCell; k++)                         // brojac celija
                        {
                            // hipoteza
                            int    toIdx = si + k * setsNum;
                            Neuron to    = ruleLayer.getNeuronAt(toIdx);
                            ConnectionFactory.createConnection(from, to, 1);
                        } // for k
                    }     // else
                }         // for si
            }             // for i

            // kreiraj izlazni sloj
            neuronProperties = new NeuronProperties();
            neuronProperties.setProperty("transferFunction", TransferFunctionType.Step.ToString());
            Layer outLayer = LayerFactory.createLayer(outNum, neuronProperties);

            this.addLayer(outLayer);

            ConnectionFactory.fullConnect(ruleLayer, outLayer);

            // inicijalizuj ulazne i izlazne celije
            NeuralNetworkFactory.DefaultIO = this;

            this.LearningRule = new LMS();
        }
Пример #15
0
        /// <summary>
        /// Creates custom NFR architecture
        /// </summary>
        /// <param name="inputNum">
        ///            number of getInputsIterator </param>
        /// <param name="inputSets">
        ///            input fuzzy sets </param>
        /// <param name="outNum">
        ///            number of outputs </param>
        private void createNetwork(int inputNum, List <int> inputSets, int outNum)
        {
            // set network type
            this.NetworkType = NeuralNetworkType.NEURO_FUZZY_REASONER;

            // CREATE INPUT LAYER
            NeuronProperties neuronProperties = new NeuronProperties();
            Layer            inLayer          = LayerFactory.createLayer(inputNum, neuronProperties);

            this.addLayer(inLayer);

            // CREATE FUZZY SET LAYER
            neuronProperties.setProperty("transferFunction", TransferFunctionType.Trapezoid.ToString());
            IEnumerator <int> e = inputSets.GetEnumerator();
            int fuzzySetsNum    = 0;

            while (e.MoveNext())
            {
                int i = e.Current;
                fuzzySetsNum = fuzzySetsNum + (int)i;
            }
            Layer setLayer = LayerFactory.createLayer(fuzzySetsNum, neuronProperties);

            this.addLayer(setLayer);

            // TODO: postavi parametre funkcija pripadnosti
            // nizove sa trning elementima iznesi van klase i prosledjuj ih kao
            // parametre
            //		Iterator<Neuron> ii = setLayer.getNeuronsIterator();
            IEnumerator <int> en;            // =setLayer.neurons();
            int c = 0;

            foreach (Neuron cell in setLayer.Neurons)
            {
                //		while (ii.hasNext()) {
                //			Neuron cell = ii.next();
                Trapezoid tf = (Trapezoid)cell.TransferFunction;

                /*
                 * if (c<=3) { tf.setLeftLow(pointsSets[c][0]);
                 * tf.setLeftHigh(pointsSets[c][1]); tf.setRightLow(pointsSets[c][3]);
                 * tf.setRightHigh(pointsSets[c][2]); } else { tf.setLeftLow(timeSets[c-4][0]);
                 * tf.setLeftHigh(timeSets[c-4][1]); tf.setRightLow(timeSets[c-4][3]);
                 * tf.setRightHigh(timeSets[c-4][2]); } c++;
                 */
            }

            // createLayer connections between input and fuzzy set getLayersIterator
            int s = 0;                         // brojac celija sloja skupova (fazifikacije)

            for (int i = 0; i < inputNum; i++) // brojac ulaznih celija
            {
                Neuron from = inLayer.getNeuronAt(i);
                int    jmax = (int)inputSets[i];
                for (int j = 0; j < jmax; j++)
                {
                    Neuron to = setLayer.getNeuronAt(s);
                    ConnectionFactory.createConnection(from, to, 1);
                    s++;
                }
            }

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

            // kreiraj sloj pravila
            neuronProperties.setProperty("inputFunction", typeof(Min));
            neuronProperties.setProperty("transferFunction", util.TransferFunctionType.Linear.ToString());
            en = inputSets.GetEnumerator();
            int fuzzyAntNum = 1;

            while (en.MoveNext())
            {
                int i = en.Current;
                fuzzyAntNum = fuzzyAntNum * (int)i;
            }
            Layer ruleLayer = LayerFactory.createLayer(fuzzyAntNum, neuronProperties);

            this.addLayer(ruleLayer);

            // povezi set i rule layer

            int scIdx = 0;                     // set cell index

            for (int i = 0; i < inputNum; i++) // brojac ulaza (grupa fuzzy
            {
                // skupova)
                int setsNum = (int)inputSets[i];

                for (int si = 0; si < setsNum; si++)                 // brojac celija fuzzy
                {
                    // skupova
                    if (i == 0)
                    {
                        Neuron from        = setLayer.getNeuronAt(si);
                        int    connPerCell = fuzzyAntNum / setsNum;
                        scIdx = si;

                        for (int k = 0; k < connPerCell; k++)                         // brojac celija
                        {
                            // hipoteza
                            Neuron to = ruleLayer.getNeuronAt(si * connPerCell + k);
                            ConnectionFactory.createConnection(from, to, 1);
                        }                 // for
                    }                     // if
                    else
                    {
                        scIdx++;
                        Neuron from        = setLayer.getNeuronAt(scIdx);
                        int    connPerCell = fuzzyAntNum / setsNum;

                        for (int k = 0; k < connPerCell; k++)                         // brojac celija
                        {
                            // hipoteza
                            int    toIdx = si + k * setsNum;
                            Neuron to    = ruleLayer.getNeuronAt(toIdx);
                            ConnectionFactory.createConnection(from, to, 1);
                        } // for k
                    }     // else
                }         // for si
            }             // for i

            // set input and output cells for this network
            neuronProperties = new NeuronProperties();
            neuronProperties.setProperty("transferFunction", TransferFunctionType.Step.ToString());
            Layer outLayer = LayerFactory.createLayer(outNum, neuronProperties);

            this.addLayer(outLayer);

            ConnectionFactory.fullConnect(ruleLayer, outLayer);

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

            this.LearningRule = new LMS();
        }