/// <summary>
        /// Compare this neural network with another.
        /// To be equal it must have the same structure and matrix values.
        /// </summary>
        /// <param name="other">The other neural network.</param>
        /// <returns>True if the neural networks are equal.</returns>
        public bool Equals(FeedforwardNetwork other)
        {
            int i = 0;

            foreach (FeedforwardLayer layer in _layers)
            {
                FeedforwardLayer otherLayer = other.Layers[i++];
                if (layer.NeuronCount != otherLayer.NeuronCount)
                {
                    return(false);
                }
                if ((layer.LayerMatrix == null) && (otherLayer.LayerMatrix != null))
                {
                    return(false);
                }
                if ((layer.LayerMatrix != null) && (otherLayer.LayerMatrix == null))
                {
                    return(false);
                }
                if ((layer.LayerMatrix != null) && (otherLayer.LayerMatrix != null))
                {
                    if (!layer.LayerMatrix.Equals(otherLayer.LayerMatrix))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
        /// <summary>
        /// Clone the structure of this neural network.
        /// </summary>
        /// <returns>A cloned copy of the structure of the neural network.</returns>
        public FeedforwardNetwork CloneStructure()
        {
            FeedforwardNetwork result = new FeedforwardNetwork();

            foreach (FeedforwardLayer layer in _layers)
            {
                FeedforwardLayer cloned = new FeedforwardLayer(layer.NeuronCount);
                result.AddLayer(cloned);
            }
            return(result);
        }
        /// <summary>
        /// Prune one of the neurons from this layer.
        /// Remove all entries in this weight matrix and other layers.
        /// </summary>
        /// <param name="neuron">The neuron to prune. Zero specifies the first neuron.</param>
        public void Prune(int neuron)
        {
            if (_matrix != null) //Delete a row on this matris
            {
                LayerMatrix = MatrixMath.DeleteRow(_matrix, neuron);
            }
            FeedforwardLayer previous = PreviousLayer;

            if (previous.LayerMatrix != null) //Delete a column on the previous
            {
                previous.LayerMatrix = MatrixMath.DeleteColumn(previous.LayerMatrix, neuron);
            }
        }
 /// <summary>
 /// Add a layer to this neural network.
 /// </summary>
 /// <param name="layer">The layer to add.</param>
 public void AddLayer(FeedforwardLayer layer)
 {
     if (_outputLayer != null)
     {
         layer.PreviousLayer    = _outputLayer;
         _outputLayer.NextLayer = layer;
     }
     if (_layers.Count == 0)
     {
         _inputLayer = _outputLayer = layer;
     }
     else
     {
         _outputLayer = layer;
     }
     _layers.Add(layer);
 }