Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TNeuron.h
Go to the documentation of this file.
1 // @(#)root/mlp:$Id$
2 // Author: Christophe.Delaere@cern.ch 20/07/03
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2003, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TNeuron
13 #define ROOT_TNeuron
14 
15 #include "TNamed.h"
16 #include "TObjArray.h"
17 
18 class TTreeFormula;
19 class TSynapse;
20 class TBranch;
21 class TTree;
22 class TFormula;
23 
24 
25 class TNeuron : public TNamed {
26  friend class TSynapse;
27 
28  public:
29  enum ENeuronType { kOff, kLinear, kSigmoid, kTanh, kGauss, kSoftmax, kExternal };
30 
31  TNeuron(ENeuronType type = kSigmoid,
32  const char* name = "", const char* title = "",
33  const char* extF = "", const char* extD = "" );
34  virtual ~TNeuron() {}
35  inline TSynapse* GetPre(Int_t n) const { return (TSynapse*) fpre.At(n); }
36  inline TSynapse* GetPost(Int_t n) const { return (TSynapse*) fpost.At(n); }
37  inline TNeuron* GetInLayer(Int_t n) const { return (TNeuron*) flayer.At(n); }
38  TTreeFormula* UseBranch(TTree*, const char*);
39  Double_t GetInput() const;
40  Double_t GetValue() const;
41  Double_t GetDerivative() const;
42  Double_t GetError() const;
43  Double_t GetTarget() const;
44  Double_t GetDeDw() const;
45  Double_t GetBranch() const;
46  ENeuronType GetType() const;
47  void SetWeight(Double_t w);
48  inline Double_t GetWeight() const { return fWeight; }
49  void SetNormalisation(Double_t mean, Double_t RMS);
50  inline const Double_t* GetNormalisation() const { return fNorm; }
51  void SetNewEvent() const;
52  void SetDEDw(Double_t in);
53  inline Double_t GetDEDw() const { return fDEDw; }
54  void ForceExternalValue(Double_t value);
55  void AddInLayer(TNeuron*);
56 
57  protected:
58  Double_t Sigmoid(Double_t x) const;
59  Double_t DSigmoid(Double_t x) const;
60  void AddPre(TSynapse*);
61  void AddPost(TSynapse*);
62 
63  private:
64  TNeuron(const TNeuron&); // Not implemented
65  TNeuron& operator=(const TNeuron&); // Not implemented
66 
67  TObjArray fpre; ///< pointers to the previous level in a network
68  TObjArray fpost; ///< pointers to the next level in a network
69  TObjArray flayer; ///< pointers to the current level in a network (neurons, not synapses)
70  Double_t fWeight; ///< weight used for computation
71  Double_t fNorm[2]; ///< normalisation to mean=0, RMS=1.
72  ENeuronType fType; ///< neuron type
73  TFormula* fExtF; ///< function (external mode)
74  TFormula* fExtD; ///< derivative (external mode)
75  TTreeFormula* fFormula;///<! formula to be used for inputs and outputs
76  Int_t fIndex; ///<! index in the formula
77  Bool_t fNewInput; ///<! do we need to compute fInput again ?
78  Double_t fInput; ///<! buffer containing the last neuron input
79  Bool_t fNewValue; ///<! do we need to compute fValue again ?
80  Double_t fValue; ///<! buffer containing the last neuron output
81  Bool_t fNewDeriv; ///<! do we need to compute fDerivative again ?
82  Double_t fDerivative; ///<! buffer containing the last neuron derivative
83  Bool_t fNewDeDw; ///<! do we need to compute fDeDw again ?
84  Double_t fDeDw; ///<! buffer containing the last derivative of the error
85  Double_t fDEDw; ///<! buffer containing the sum over all examples of DeDw
86 
87  ClassDef(TNeuron, 4) // Neuron for MultiLayerPerceptrons
88 };
89 
90 #endif