Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TNeuron.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/mlp:$Id$
0002 // Author: Christophe.Delaere@cern.ch   20/07/03
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2003, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TNeuron
0013 #define ROOT_TNeuron
0014 
0015 #include "TNamed.h"
0016 #include "TObjArray.h"
0017 
0018 class TTreeFormula;
0019 class TSynapse;
0020 class TBranch;
0021 class TTree;
0022 class TFormula;
0023 
0024 
0025 class TNeuron : public TNamed {
0026    friend class TSynapse;
0027 
0028  public:
0029    enum ENeuronType { kOff, kLinear, kSigmoid, kTanh, kGauss, kSoftmax, kExternal };
0030 
0031    TNeuron(ENeuronType type = kSigmoid,
0032            const char* name = "", const char* title = "",
0033            const char* extF = "", const char* extD  = "" );
0034    ~TNeuron() override {}
0035    inline TSynapse* GetPre(Int_t n) const { return (TSynapse*) fpre.At(n); }
0036    inline TSynapse* GetPost(Int_t n) const { return (TSynapse*) fpost.At(n); }
0037    inline TNeuron* GetInLayer(Int_t n) const { return (TNeuron*) flayer.At(n); }
0038    TTreeFormula* UseBranch(TTree*, const char*);
0039    Double_t GetInput() const;
0040    Double_t GetValue() const;
0041    Double_t GetDerivative() const;
0042    Double_t GetError() const;
0043    Double_t GetTarget() const;
0044    Double_t GetDeDw() const;
0045    Double_t GetBranch() const;
0046    ENeuronType GetType() const;
0047    void SetWeight(Double_t w);
0048    inline Double_t GetWeight() const { return fWeight; }
0049    void SetNormalisation(Double_t mean, Double_t RMS);
0050    inline const Double_t* GetNormalisation() const { return fNorm; }
0051    void SetNewEvent() const;
0052    void SetDEDw(Double_t in);
0053    inline Double_t GetDEDw() const { return fDEDw; }
0054    void ForceExternalValue(Double_t value);
0055    void AddInLayer(TNeuron*);
0056 
0057  protected:
0058    Double_t Sigmoid(Double_t x) const;
0059    Double_t DSigmoid(Double_t x) const;
0060    void AddPre(TSynapse*);
0061    void AddPost(TSynapse*);
0062 
0063  private:
0064    TNeuron(const TNeuron&); // Not implemented
0065    TNeuron& operator=(const TNeuron&); // Not implemented
0066 
0067    TObjArray fpre;        ///< pointers to the previous level in a network
0068    TObjArray fpost;       ///< pointers to the next level in a network
0069    TObjArray flayer;      ///< pointers to the current level in a network (neurons, not synapses)
0070    Double_t fWeight;      ///< weight used for computation
0071    Double_t fNorm[2];     ///< normalisation to mean=0, RMS=1.
0072    ENeuronType fType;     ///< neuron type
0073    TFormula* fExtF;       ///< function   (external mode)
0074    TFormula* fExtD;       ///< derivative (external mode)
0075    TTreeFormula* fFormula;///<! formula to be used for inputs and outputs
0076    Int_t fIndex;          ///<! index in the formula
0077    Bool_t fNewInput;      ///<! do we need to compute fInput again ?
0078    Double_t fInput;       ///<! buffer containing the last neuron input
0079    Bool_t fNewValue;      ///<! do we need to compute fValue again ?
0080    Double_t fValue;       ///<! buffer containing the last neuron output
0081    Bool_t fNewDeriv;      ///<! do we need to compute fDerivative again ?
0082    Double_t fDerivative;  ///<! buffer containing the last neuron derivative
0083    Bool_t fNewDeDw;       ///<! do we need to compute fDeDw again ?
0084    Double_t fDeDw;        ///<! buffer containing the last derivative of the error
0085    Double_t fDEDw;        ///<! buffer containing the sum over all examples of DeDw
0086 
0087    ClassDefOverride(TNeuron, 4)   // Neuron for MultiLayerPerceptrons
0088 };
0089 
0090 #endif