Beispiel #1
0
        public NeuralNetwork(params uint[] topology)
        {
            this.Topology = topology;

            //Calculate overall weight count
            WeightCount = 0;
            for (int i = 0; i < topology.Length - 1; i++)
            {
                WeightCount += (int)((topology[i] + 1) * topology[i + 1]); // + 1 for bias node
            }
            //Initialise layers
            Layers = new NeuralLayer[topology.Length - 1];
            for (int i = 0; i < Layers.Length; i++)
            {
                Layers[i] = new NeuralLayer(topology[i], topology[i + 1]);
            }
        }
Beispiel #2
0
        public NeuralLayer DeepCopy()
        {
            double[,] copiedWeights = new double[this.Weights.GetLength(0), this.Weights.GetLength(1)];

            for (int x = 0; x < this.Weights.GetLength(0); x++)
            {
                for (int y = 0; y < this.Weights.GetLength(1); y++)
                {
                    copiedWeights[x, y] = this.Weights[x, y];
                }
            }

            //Create copy
            NeuralLayer newLayer = new NeuralLayer(this.NeuronCount, this.OutputCount);

            newLayer.Weights = copiedWeights;
            newLayer.NeuronActivationFunction = this.NeuronActivationFunction;

            return(newLayer);
        }