/// <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>
        /// Calculate the error for the recognition just done.
        /// </summary>
        /// <param name="ideal">What the output neurons should have yielded.</param>
        public void CalcError(double[] ideal)
        {
            if (ideal.Length != this.network.OutputLayer.NeuronCount)
            {
                throw new NeuralNetworkError(
                          "Size mismatch: Can't calcError for ideal input size="
                          + ideal.Length + " for output layer size="
                          + this.network.OutputLayer.NeuronCount);
            }

            // clear out all previous error data
            foreach (FeedforwardLayer layer in this.network.Layers)
            {
                GetBackpropagationLayer(layer).ClearError();
            }

            for (int i = this.network.Layers.Count - 1; i >= 0; i--)
            {
                FeedforwardLayer layer = this.network.Layers[i];
                if (layer.IsOutput())
                {
                    GetBackpropagationLayer(layer).CalcError(ideal);
                }
                else
                {
                    GetBackpropagationLayer(layer).CalcError();
                }
            }
        }
        /// <summary>
        /// Get the BackpropagationLayer that corresponds to the specified layer.
        /// </summary>
        /// <param name="layer">The specified layer.</param>
        /// <returns>The BackpropagationLayer that corresponds to the specified layer.</returns>
        public BackpropagationLayer GetBackpropagationLayer(
            FeedforwardLayer layer)
        {
            BackpropagationLayer result = this.layerMap[layer];

            if (result == null)
            {
                throw new NeuralNetworkError(
                          "Layer unknown to backpropagation trainer, was a layer added after training begain?");
            }

            return(result);
        }
        public BackpropagationLayer(Backpropagation parent, FeedforwardLayer layer)
        {
            this.parent = parent;
            this.layer = layer;

            error = new double[layer.NeuronCount];
            errorDelta = new double[layer.NeuronCount];

            if (layer.Next != null)
            {
                accumulatedMatrixDelta = new Matrix(layer.NeuronCount + 1, layer.Next.NeuronCount);
                previousMatrixDelta = new Matrix(layer.NeuronCount + 1, layer.Next.NeuronCount);
                biasRow = layer.NeuronCount;
            }
        }
        public BackpropagationLayer(Backpropagation parent, FeedforwardLayer layer)
        {
            _parent = parent;
            _layer  = layer;

            _error      = new double[layer.NeuronCount];
            _errorDelta = new double[layer.NeuronCount];

            if (layer.Next != null)
            {
                _accumulatedMatrixDelta = new Matrix(layer.NeuronCount + 1, layer.Next.NeuronCount);
                _previousMatrixDelta    = new Matrix(layer.NeuronCount + 1, layer.Next.NeuronCount);
                _biasRow = layer.NeuronCount;
            }
        }
示例#6
0
        /// <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;
            }
        }
示例#7
0
        /// <summary>
        /// Get the BackpropagationLayer that corresponds to the specified layer.
        /// </summary>
        /// <param name="layer">The specified layer.</param>
        /// <returns>The BackpropagationLayer that corresponds to the specified layer.</returns>
        public BackpropagationLayer GetBackpropagationLayer(
                 FeedforwardLayer layer)
        {
            BackpropagationLayer result = this.layerMap[layer];

            if (result == null)
            {
                throw new NeuralNetworkError(
                        "Layer unknown to backpropagation trainer, was a layer added after training begain?");
            }

            return result;
        }
示例#8
0
 public BackpropagationLayer GetBackpropagationLayer(FeedforwardLayer layer)
 {
     return(_layerMapping[layer]);
 }
示例#9
0
 public BackpropagationLayer GetBackpropagationLayer(FeedforwardLayer layer)
 {
     return _layerMapping[layer];
 }