Ejemplo n.º 1
0
        /// <summary>
        /// Return a clone of 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 this.layers)
            {
                FeedforwardLayer clonedLayer = new FeedforwardLayer(layer.NeuronCount);
                result.AddLayer(clonedLayer);
            }

            return result;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add a layer to the neural network. The first layer added is the input
        /// layer, the last layer added is the output layer.
        /// </summary>
        /// <param name="layer">The layer to be added.</param>
        public void AddLayer(FeedforwardLayer layer)
        {
            // setup the forward and back pointer
            if (this.outputLayer != null)
            {
                layer.Previous = this.outputLayer;
                this.outputLayer.Next = layer;
            }

            // update the inputLayer and outputLayer variables
            if (this.layers.Count == 0)
            {
                this.inputLayer = this.outputLayer = layer;
            }
            else
            {
                this.outputLayer = layer;
            }

            // add the new layer to the list
            this.layers.Add(layer);
        }