Esempio n. 1
0
        public Network(int InputLayerSize, int[] HiddenLayerSizes, int OutputLayerSize, Function[] activationFuncs)
        {
            Random r = new Random();

            //will create a network with InputLayerSize inputneurons, HiddenLayerSizes.count Hiddenlayers (Each with the size of the array at that position), and OutputLayerSize outputneurons

            /*****************************
             * InputNeurons
             ****************************/
            InputLayer = new InputLayer(InputLayerSize, this);

            /*****************************
             * HiddenNeurons
             ****************************/

            hiddenLayer = new HiddenLayer[HiddenLayerSizes.Length];

            for (int i = 0; i < hiddenLayer.Length; i++) //for each layer
            {
                hiddenLayer[i] = new HiddenLayer(HiddenLayerSizes[i], this);
                if (i == 0)
                {
                    hiddenLayer[i].connectToInputLayer(InputLayer);//connect the hiddenlayer to the inputlayer
                }
                else
                {
                    hiddenLayer[i].connectToInputLayer(hiddenLayer[i - 1]);//connect the hiddenlayer to the hiddenlayer before
                }
                hiddenLayer[i].ActivationFunction = activationFuncs[i];
            }

            /*****************************
             * OutputNeurons
             ****************************/
            outputLayer = new OutputLayer(OutputLayerSize, this);
            outputLayer.connectToInputLayer(hiddenLayer[HiddenLayerSizes.Length - 1]);
            outputLayer.ActivationFunction = activationFuncs[activationFuncs.Length - 1];
            this.RandomizeAllWeights();
            this.DatabaseID = db.getNetworkID();
        }