Logo ROOT  
Reference Guide
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
18class TTreeFormula;
19class TSynapse;
20class TBranch;
21class TTree;
22class TFormula;
23
24
25class TNeuron : public TNamed {
26 friend class TSynapse;
27
28 public:
30
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; }
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:
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
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
#define ClassDef(name, id)
Definition: Rtypes.h:326
char name[80]
Definition: TGX11.cxx:109
int type
Definition: TGX11.cxx:120
A TTree is a list of TBranches.
Definition: TBranch.h:91
The Formula class.
Definition: TFormula.h:84
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
This class describes an elementary neuron, which is the basic element for a Neural Network.
Definition: TNeuron.h:25
Double_t GetDerivative() const
computes the derivative for the appropriate function at the working point
Definition: TNeuron.cxx:1009
Double_t fWeight
weight used for computation
Definition: TNeuron.h:70
TObjArray fpost
pointers to the next level in a network
Definition: TNeuron.h:68
Double_t GetWeight() const
Definition: TNeuron.h:48
void SetWeight(Double_t w)
Sets the neuron weight to w.
Definition: TNeuron.cxx:1146
TNeuron(ENeuronType type=kSigmoid, const char *name="", const char *title="", const char *extF="", const char *extD="")
Usual constructor.
Definition: TNeuron.cxx:49
TObjArray flayer
pointers to the current level in a network (neurons, not synapses)
Definition: TNeuron.h:69
TFormula * fExtD
derivative (external mode)
Definition: TNeuron.h:74
Double_t fDerivative
! buffer containing the last neuron derivative
Definition: TNeuron.h:82
Bool_t fNewInput
! do we need to compute fInput again ?
Definition: TNeuron.h:77
TTreeFormula * fFormula
! formula to be used for inputs and outputs
Definition: TNeuron.h:75
Double_t GetDEDw() const
Definition: TNeuron.h:53
Int_t fIndex
! index in the formula
Definition: TNeuron.h:76
Double_t fDEDw
! buffer containing the sum over all examples of DeDw
Definition: TNeuron.h:85
Double_t GetValue() const
Computes the output using the appropriate function and all the weighted inputs, or uses the branch as...
Definition: TNeuron.cxx:946
Double_t Sigmoid(Double_t x) const
The Sigmoid.
Definition: TNeuron.cxx:93
Double_t fDeDw
! buffer containing the last derivative of the error
Definition: TNeuron.h:84
void SetDEDw(Double_t in)
Sets the derivative of the total error wrt the neuron weight.
Definition: TNeuron.cxx:1166
Double_t GetDeDw() const
Computes the derivative of the error wrt the neuron weight.
Definition: TNeuron.cxx:1082
Double_t GetBranch() const
Returns the formula value.
Definition: TNeuron.cxx:912
TNeuron * GetInLayer(Int_t n) const
Definition: TNeuron.h:37
Double_t GetError() const
Computes the error for output neurons.
Definition: TNeuron.cxx:1061
Bool_t fNewValue
! do we need to compute fValue again ?
Definition: TNeuron.h:79
void AddPost(TSynapse *)
Adds a synapse to the neuron as an output This method is used by the TSynapse while connecting two ne...
Definition: TNeuron.cxx:844
TTreeFormula * UseBranch(TTree *, const char *)
Sets a formula that can be used to make the neuron an input.
Definition: TNeuron.cxx:876
TSynapse * GetPre(Int_t n) const
Definition: TNeuron.h:35
Bool_t fNewDeriv
! do we need to compute fDerivative again ?
Definition: TNeuron.h:81
void ForceExternalValue(Double_t value)
Uses the branch type to force an external value.
Definition: TNeuron.cxx:1123
Double_t fInput
! buffer containing the last neuron input
Definition: TNeuron.h:78
TSynapse * GetPost(Int_t n) const
Definition: TNeuron.h:36
Double_t GetTarget() const
Computes the normalized target pattern for output neurons.
Definition: TNeuron.cxx:1072
Double_t fNorm[2]
normalisation to mean=0, RMS=1.
Definition: TNeuron.h:71
Double_t GetInput() const
Returns neuron input.
Definition: TNeuron.cxx:923
virtual ~TNeuron()
Definition: TNeuron.h:34
const Double_t * GetNormalisation() const
Definition: TNeuron.h:50
Double_t DSigmoid(Double_t x) const
The Derivative of the Sigmoid.
Definition: TNeuron.cxx:816
ENeuronType fType
neuron type
Definition: TNeuron.h:72
void AddPre(TSynapse *)
Adds a synapse to the neuron as an input This method is used by the TSynapse while connecting two neu...
Definition: TNeuron.cxx:832
TNeuron & operator=(const TNeuron &)
TFormula * fExtF
function (external mode)
Definition: TNeuron.h:73
ENeuronType GetType() const
Returns the neuron type.
Definition: TNeuron.cxx:865
Bool_t fNewDeDw
! do we need to compute fDeDw again ?
Definition: TNeuron.h:83
Double_t fValue
! buffer containing the last neuron output
Definition: TNeuron.h:80
void SetNewEvent() const
Inform the neuron that inputs of the network have changed, so that the buffered values have to be rec...
Definition: TNeuron.cxx:1155
void SetNormalisation(Double_t mean, Double_t RMS)
Sets the normalization variables.
Definition: TNeuron.cxx:1135
void AddInLayer(TNeuron *)
Tells a neuron which neurons form its layer (including itself).
Definition: TNeuron.cxx:855
ENeuronType
Definition: TNeuron.h:29
@ kLinear
Definition: TNeuron.h:29
@ kSigmoid
Definition: TNeuron.h:29
@ kExternal
Definition: TNeuron.h:29
@ kSoftmax
Definition: TNeuron.h:29
@ kGauss
Definition: TNeuron.h:29
@ kOff
Definition: TNeuron.h:29
@ kTanh
Definition: TNeuron.h:29
TObjArray fpre
pointers to the previous level in a network
Definition: TNeuron.h:67
An array of TObjects.
Definition: TObjArray.h:37
TObject * At(Int_t idx) const
Definition: TObjArray.h:166
This is a simple weighted bidirectional connection between two neurons.
Definition: TSynapse.h:20
Used to pass a selection expression to the Tree drawing routine.
Definition: TTreeFormula.h:58
A TTree represents a columnar dataset.
Definition: TTree.h:72
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
Double_t RMS(Long64_t n, const T *a, const Double_t *w=0)
Return the Standard Deviation of an array a with length n.
Definition: TMath.h:1157