public HiddenLayer(uint numberOfNeurons, Layer previous) : base(numberOfNeurons) { this.previousLayer = previous; // default activation function is logsig this.activationFunction = ActivationFunction.LogSig; this.pointer = new ToActivationFunction(NMath.LogSig); this.pDeriv = new ToActivationDerivative(NMath.DLogSig); this.input = previous.GetOutputVector(); // try { layerNeurons = new Neuron[numberOfNeurons]; // for(int i=0; i<numberOfNeurons; i++) { layerNeurons[i] = new Neuron(previous.GetSize()); layerNeurons[i].SetInputVector(input); } // } catch(System.Exception exception) { Console.WriteLine("****EXCEPTION****\n {0} {1}", exception.Message); previousLayer = null; pointer = null; layerNeurons = null; } }
// public void FeedForward(ToActivationFunction pointer) { double neuronInput = 0.0; // for(int i=0; i<weights.Length; i++) { neuronInput += input[i]*weights[i]; } // // add bias neuronInput += bias; // pass neuron input to activation function and get output output = pointer(neuronInput); }
// public void SetActivationFunction(ActivationFunction af) { this.activationFunction = af; // switch(af) { case ActivationFunction.LogSig: this.pointer = new ToActivationFunction(NMath.LogSig); this.pDeriv = new ToActivationDerivative(NMath.DLogSig); break; case ActivationFunction.TanSig: this.pointer = new ToActivationFunction(NMath.TanSig); this.pDeriv = new ToActivationDerivative(NMath.DTanSig); break; case ActivationFunction.Linear: this.pointer = new ToActivationFunction(NMath.Linear); this.pDeriv = new ToActivationDerivative(NMath.DLinear); break; default: break; } }