Encog.Neural.Networks.BasicNetwork.AddLayer C# (CSharp) Method

AddLayer() public method

Add a layer to the neural network. If there are no layers added this layer will become the input layer. This function automatically updates both the input and output layer references.
public AddLayer ( ILayer layer ) : void
layer ILayer The layer to be added to the network.
return void
        public void AddLayer(ILayer layer)
        {
            layer.Network = this;
            _structure.Layers.Add(layer);
        }

Usage Example

        private void Preprocessing_Completed(object sender, RunWorkerCompletedEventArgs e)
        {
            worker.ReportProgress(0, "Creating Network...");
            BasicNetwork Network = new BasicNetwork();
            Network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, DataContainer.NeuralNetwork.Data.InputSize));
            Network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, 50));
            Network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, DataContainer.NeuralNetwork.Data.IdealSize));
            Network.Structure.FinalizeStructure();
            Network.Reset();
            DataContainer.NeuralNetwork.Network = Network;

            ResilientPropagation training = new ResilientPropagation(DataContainer.NeuralNetwork.Network, DataContainer.NeuralNetwork.Data);
            worker.ReportProgress(0, "Running Training: Epoch 0");
            for(int i = 0; i < 200; i++)
            {
                training.Iteration();
                worker.ReportProgress(0, "Running Training: Epoch " + (i+1).ToString() + "     Current Training Error : " + training.Error.ToString());
                if(worker.CancellationPending == true)
                {
                    completed = true;
                    return;
                }

            }
            completed = true;
        }
All Usage Examples Of Encog.Neural.Networks.BasicNetwork::AddLayer