#ifndef NEURAL_NEURON_H #define NEURAL_NEURON_H #include "neural/node.h" #include "neural/slope.h" namespace Neural { template class Neuron : public Node { public: Neuron() : iInputs( 0 ), aWeights( 0 ), sBias( 0.0 ), pSlope( 0 ) { } virtual ~Neuron() { delete[] aWeights; delete pSlope; } virtual void finalize( int iNumInputs ) { iInputs = iNumInputs; aWeights = new sigtype[iInputs]; } virtual void process( sigtype *aInput, sigtype *aOutput ) { sigtype sOutput = sBias; for( int j = 0; j < iInputs; j++ ) { sOutput += aWeights[j] * aInput[j]; } *aOutput = (*pSlope)( sOutput ); } virtual int getNumInputs() const { return iInputs; } virtual int getNumOutputs() const { return 1; } virtual int getNumWeights() const { return iInputs; } virtual int getNumBiases() const { return 1; } private: int iInputs; sigtype *aWeights; sigtype sBias; Slope *pSlope; }; }; #endif