00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TNeuron
00013 #define ROOT_TNeuron
00014
00015 #ifndef ROOT_TNamed
00016 #include "TNamed.h"
00017 #endif
00018 #ifndef ROOT_TObjArray
00019 #include "TObjArray.h"
00020 #endif
00021
00022 class TTreeFormula;
00023 class TSynapse;
00024 class TBranch;
00025 class TTree;
00026 class TFormula;
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 class TNeuron : public TNamed {
00049 friend class TSynapse;
00050
00051 public:
00052 enum ENeuronType { kOff, kLinear, kSigmoid, kTanh, kGauss, kSoftmax, kExternal };
00053
00054 TNeuron(ENeuronType type = kSigmoid,
00055 const char* name = "", const char* title = "",
00056 const char* extF = "", const char* extD = "" );
00057 virtual ~TNeuron() {}
00058 inline TSynapse* GetPre(Int_t n) const { return (TSynapse*) fpre.At(n); }
00059 inline TSynapse* GetPost(Int_t n) const { return (TSynapse*) fpost.At(n); }
00060 inline TNeuron* GetInLayer(Int_t n) const { return (TNeuron*) flayer.At(n); }
00061 TTreeFormula* UseBranch(TTree*, const char*);
00062 Double_t GetInput() const;
00063 Double_t GetValue() const;
00064 Double_t GetDerivative() const;
00065 Double_t GetError() const;
00066 Double_t GetTarget() const;
00067 Double_t GetDeDw() const;
00068 Double_t GetBranch() const;
00069 ENeuronType GetType() const;
00070 void SetWeight(Double_t w);
00071 inline Double_t GetWeight() const { return fWeight; }
00072 void SetNormalisation(Double_t mean, Double_t RMS);
00073 inline const Double_t* GetNormalisation() const { return fNorm; }
00074 void SetNewEvent() const;
00075 void SetDEDw(Double_t in);
00076 inline Double_t GetDEDw() const { return fDEDw; }
00077 void ForceExternalValue(Double_t value);
00078 void AddInLayer(TNeuron*);
00079
00080 protected:
00081 Double_t Sigmoid(Double_t x) const;
00082 Double_t DSigmoid(Double_t x) const;
00083 void AddPre(TSynapse*);
00084 void AddPost(TSynapse*);
00085
00086 private:
00087 TNeuron(const TNeuron&);
00088 TNeuron& operator=(const TNeuron&);
00089
00090 TObjArray fpre;
00091 TObjArray fpost;
00092 TObjArray flayer;
00093 Double_t fWeight;
00094 Double_t fNorm[2];
00095 ENeuronType fType;
00096 TFormula* fExtF;
00097 TFormula* fExtD;
00098
00099
00100 TTreeFormula* fFormula;
00101 Int_t fIndex;
00102 Bool_t fNewInput;
00103 Double_t fInput;
00104 Bool_t fNewValue;
00105 Double_t fValue;
00106 Bool_t fNewDeriv;
00107 Double_t fDerivative;
00108 Bool_t fNewDeDw;
00109 Double_t fDeDw;
00110 Double_t fDEDw;
00111
00112 ClassDef(TNeuron, 4)
00113 };
00114
00115 #endif