Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 ~TNeuron() override {}
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; }
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 ClassDefOverride(TNeuron, 4) // Neuron for MultiLayerPerceptrons
88};
89
90#endif
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:110
A TTree is a list of TBranches.
Definition TBranch.h:93
The Formula class.
Definition TFormula.h:87
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:1007
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:1144
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:944
Double_t Sigmoid(Double_t x) const
The Sigmoid.
Definition TNeuron.cxx:91
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:1164
Double_t GetDeDw() const
Computes the derivative of the error wrt the neuron weight.
Definition TNeuron.cxx:1080
Double_t GetBranch() const
Returns the formula value.
Definition TNeuron.cxx:910
TNeuron * GetInLayer(Int_t n) const
Definition TNeuron.h:37
Double_t GetError() const
Computes the error for output neurons.
Definition TNeuron.cxx:1059
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:842
TTreeFormula * UseBranch(TTree *, const char *)
Sets a formula that can be used to make the neuron an input.
Definition TNeuron.cxx:874
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:1121
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:1070
Double_t fNorm[2]
normalisation to mean=0, RMS=1.
Definition TNeuron.h:71
Double_t GetInput() const
Returns neuron input.
Definition TNeuron.cxx:921
const Double_t * GetNormalisation() const
Definition TNeuron.h:50
Double_t DSigmoid(Double_t x) const
The Derivative of the Sigmoid.
Definition TNeuron.cxx:814
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:830
TNeuron & operator=(const TNeuron &)
TFormula * fExtF
function (external mode)
Definition TNeuron.h:73
ENeuronType GetType() const
Returns the neuron type.
Definition TNeuron.cxx:863
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:1153
void SetNormalisation(Double_t mean, Double_t RMS)
Sets the normalization variables.
Definition TNeuron.cxx:1133
void AddInLayer(TNeuron *)
Tells a neuron which neurons form its layer (including itself).
Definition TNeuron.cxx:853
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
~TNeuron() override
Definition TNeuron.h:34
TObjArray fpre
pointers to the previous level in a network
Definition TNeuron.h:67
An array of TObjects.
Definition TObjArray.h:31
TObject * At(Int_t idx) const override
Definition TObjArray.h:164
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.
A TTree represents a columnar dataset.
Definition TTree.h:79
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16