#ifndef NEURON_H #define NEURON_H /////////////////////////////////////////////////////////////// // neuron.h - neuron family used in neural net // // ver 1.0 // // // // Language: Visual C++, ver 6.0 // // Platform: Dell XPS B1000r, Windows 2000 // // Application: Prototype for Pr#1, ELE 591/791 // // Author: Jim Fawcett, CST 2-187, Syracuse Univ // // (315) 443-3948, jfawcett@twcny.rr.com // /////////////////////////////////////////////////////////////// /* Module Contents =============== This module defines a hierarchy of neurons. The neuron class is abstract base, defining a protocol for a family of neuron types, used in neural nets. Three derived types are declared here: linearNeuron - used in output layers, SigmoidNeuron - used in hidden layers, and sgnNeuron - used later in the course. Only linearNeuron operations are defined in this prototype module. Operations ========== linearNeuron ln(4); declare linear neuron with 4 inputs ln.input(2,0.5); set 3rd input to value of 0.5 ln.weight(1,0.75); set 2nd weight to value of 0.75 ln.size(); returns number of inputs linearNeuron *pLn = ln.clone(); returns pointer to new copy of ln on heap double out = ln.output(); returns neuron's output double slp = ln.slope(); returns neuron's slope at current input set ln.showInputs(); displays neurons inputs on std output ln.showWeights(); displays neurons weights on std output */ // /////////////////////////////////////////////////////////////// // Build Process // /////////////////////////////////////////////////////////////// // Required Files: // // layer.h, layer.cpp, neuron.h, neuron.cpp // // // // Compiler Command: // // cl /GX /DTEST_LAYER layer.cpp neuron.cpp // /////////////////////////////////////////////////////////////// /* Maintenance History =================== ver 1.0 : 8 Jun 2000 - first release - this is a prototype defining only linear neurons */ // #include /////////////////////////////////////////////////////////////// // neuron - abstract base neuron class class neuron { public: virtual ~neuron() { } void input (int select, double value); void weight(int select, double value); void showInputs(); void showWeights(); int size(); virtual neuron* clone() = 0; virtual double output() = 0; virtual double slope() = 0; protected: std::vector _inputs; std::vector _weights; }; inline neuron::size() { return _inputs.size(); } /////////////////////////////////////////////////////////////// // sigmoidNeuron - derived neuron class with sigmoid nonlinearity class sigmoidNeuron : public neuron { public: sigmoidNeuron(int numInputs); virtual neuron* clone(); virtual double output(); virtual double slope(); }; /////////////////////////////////////////////////////////////// // linearNeuron - derived neuron class with linear function class linearNeuron : public neuron { public: linearNeuron(int numInputs); virtual neuron* clone(); virtual double output(); virtual double slope(); }; // /////////////////////////////////////////////////////////////// // sgnNeuron - derived neuron class with sgn nonlinearity class sgnNeuron : public neuron { public: sgnNeuron(int numInputs); virtual neuron* clone(); virtual double output(); virtual double slope(); }; #endif