Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TSynapse.cxx
Go to the documentation of this file.
1// @(#)root/mlp:$Id$
2// Author: Christophe.Delaere@cern.ch 21/08/2002
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/** \class TSynapse
13
14This is a simple weighted bidirectional connection between
15two neurons.
16A network is built connecting two neurons by a synapse.
17In addition to the value, the synapse can return the DeDw
18
19*/
20
21#include "TSynapse.h"
22#include "TNeuron.h"
23
24
25////////////////////////////////////////////////////////////////////////////////
26/// Default constructor
27
29{
30 fpre = nullptr;
31 fpost = nullptr;
32 fweight = 1;
33 fDEDw = 0;
34}
35
36////////////////////////////////////////////////////////////////////////////////
37/// Constructor that connects two neurons
38
40{
41 fpre = pre;
42 fpost = post;
43 fweight = w;
44 fDEDw = 0;
45 pre->AddPost(this);
46 post->AddPre(this);
47}
48
49////////////////////////////////////////////////////////////////////////////////
50/// Sets the pre-neuron
51
53{
54 if (fpre) {
55 Error("SetPre","this synapse is already assigned to a pre-neuron.");
56 return;
57 }
58 fpre = pre;
59 pre->AddPost(this);
60}
61
62////////////////////////////////////////////////////////////////////////////////
63/// Sets the post-neuron
64
66{
67 if (fpost) {
68 Error("SetPost","this synapse is already assigned to a post-neuron.");
69 return;
70 }
71 fpost = post;
72 post->AddPre(this);
73}
74
75////////////////////////////////////////////////////////////////////////////////
76/// Returns the value: weighted input
77
79{
80 if (fpre)
81 return (fweight * fpre->GetValue());
82 return 0;
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Computes the derivative of the error wrt the synapse weight.
87
89{
90 if (!(fpre && fpost))
91 return 0;
92 return (fpre->GetValue() * fpost->GetDeDw());
93}
94
95////////////////////////////////////////////////////////////////////////////////
96/// Sets the weight of the synapse.
97/// This weight is the multiplying factor applied on the
98/// output of a neuron in the linear combination given as input
99/// of another neuron.
100
102{
103 fweight = w;
104}
105
106////////////////////////////////////////////////////////////////////////////////
107/// Sets the derivative of the total error wrt the synapse weight
108
110{
111 fDEDw = in;
112}
113
114
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
This class describes an elementary neuron, which is the basic element for a Neural Network.
Definition TNeuron.h:25
Double_t GetValue() const
Computes the output using the appropriate function and all the weighted inputs, or uses the branch as...
Definition TNeuron.cxx:943
Double_t GetDeDw() const
Computes the derivative of the error wrt the neuron weight.
Definition TNeuron.cxx:1079
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
TNeuron * fpre
the neuron before the synapse
Definition TSynapse.h:37
void SetPre(TNeuron *pre)
Sets the pre-neuron.
Definition TSynapse.cxx:52
Double_t GetDeDw() const
Computes the derivative of the error wrt the synapse weight.
Definition TSynapse.cxx:88
TNeuron * fpost
the neuron after the synapse
Definition TSynapse.h:38
void SetPost(TNeuron *post)
Sets the post-neuron.
Definition TSynapse.cxx:65
Double_t fDEDw
! the derivative of the total error wrt the synapse weight
Definition TSynapse.h:40
Double_t fweight
the weight of the synapse
Definition TSynapse.h:39
void SetWeight(Double_t w)
Sets the weight of the synapse.
Definition TSynapse.cxx:101
Double_t GetValue() const
Returns the value: weighted input.
Definition TSynapse.cxx:78
void SetDEDw(Double_t in)
Sets the derivative of the total error wrt the synapse weight.
Definition TSynapse.cxx:109
TSynapse()
Default constructor.
Definition TSynapse.cxx:28