/// <summary>
        /// Construct a BackpropagationLayer object that corresponds to a specific neuron layer.
        /// </summary>
        /// <param name="backpropagation">The back propagation training object.</param>
        /// <param name="layer">The layer that this object corresponds to.</param>
        public BackpropagationLayer(Backpropagation backpropagation,
                 FeedforwardLayer layer)
        {
            this.backpropagation = backpropagation;
            this.layer = layer;

            int neuronCount = layer.NeuronCount;

            this.error = new double[neuronCount];
            this.errorDelta = new double[neuronCount];

            if (layer.Next != null)
            {
                this.accMatrixDelta = new Matrix.Matrix(layer.NeuronCount + 1, layer.Next.NeuronCount);
                this.matrixDelta = new Matrix.Matrix(layer.NeuronCount + 1, layer.Next.NeuronCount);
                this.biasRow = layer.NeuronCount;
            }
        }
        /// <summary>
        /// Construct a BackpropagationLayer object that corresponds to a specific neuron layer.
        /// </summary>
        /// <param name="backpropagation">The back propagation training object.</param>
        /// <param name="layer">The layer that this object corresponds to.</param>
        public BackpropagationLayer(Backpropagation backpropagation,
                                    FeedforwardLayer layer)
        {
            this.backpropagation = backpropagation;
            this.layer           = layer;

            int neuronCount = layer.NeuronCount;

            this.error      = new double[neuronCount];
            this.errorDelta = new double[neuronCount];

            if (layer.Next != null)
            {
                this.accMatrixDelta = new Matrix.Matrix(layer.NeuronCount + 1, layer.Next.NeuronCount);
                this.matrixDelta    = new Matrix.Matrix(layer.NeuronCount + 1, layer.Next.NeuronCount);
                this.biasRow        = layer.NeuronCount;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Method that is called to start the incremental prune process.
        /// </summary>
        public void StartIncremental()
        {
            this.hiddenNeuronCount = 1;
            this.cycles = 0;
            this.done = false;

            this.currentNetwork = new FeedforwardNetwork();
            this.currentNetwork
                    .AddLayer(new FeedforwardLayer(this.train[0].Length));
            this.currentNetwork.AddLayer(new FeedforwardLayer(
                    this.hiddenNeuronCount));
            this.currentNetwork
                    .AddLayer(new FeedforwardLayer(this.ideal[0].Length));
            this.currentNetwork.Reset();

            this.backprop = new Backpropagation(this.currentNetwork, this.train,
                    this.ideal, this.rate, this.momentum);

        }
Esempio n. 4
0
        /// <summary>
        /// Internal method that is called at the end of each incremental cycle.
        /// </summary>
        protected void Increment()
        {
            bool doit = false;

            if (this.markErrorRate == 0)
            {
                this.markErrorRate = this.error;
                this.sinceMark = 0;
            }
            else
            {
                this.sinceMark++;
                if (this.sinceMark > 10000)
                {
                    if ((this.markErrorRate - this.error) < 0.01)
                    {
                        doit = true;
                    }
                    this.markErrorRate = this.error;
                    this.sinceMark = 0;
                }
            }

            if (this.error < this.maxError)
            {
                this.done = true;
            }

            if (doit)
            {
                this.cycles = 0;
                this.hiddenNeuronCount++;

                this.currentNetwork = new FeedforwardNetwork();
                this.currentNetwork.AddLayer(new FeedforwardLayer(
                        this.train[0].Length));
                this.currentNetwork.AddLayer(new FeedforwardLayer(
                        this.hiddenNeuronCount));
                this.currentNetwork.AddLayer(new FeedforwardLayer(
                        this.ideal[0].Length));
                this.currentNetwork.Reset();

                this.backprop = new Backpropagation(this.currentNetwork,
                        this.train, this.ideal, this.rate, this.momentum);
            }
        }