Calculus On Computational Graphs - An Introduction: February 2021
Calculus On Computational Graphs - An Introduction: February 2021
net/publication/348978259
CITATIONS READS
0 34
1 author:
Johnson Agbinya
Melbourne Institute of Technology
202 PUBLICATIONS 1,838 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Johnson Agbinya on 03 February 2021.
6
Calculus on Computational Graphs
6.1 Introduction
Fast, accurate and reliable computational schemes are essential when
implementing complex systems required in deep learning applications. One
of the techniques for achieving this is the so-called computational graph.
Computational graphs divide down a complex computation into small and
executable steps which could be performed quickly with pencil and paper
and better still with computers. In most cases, loops that require repeating of
the same algorithm but wastes time computationally due to processing of loop
times become a lot easier to handle. Computational graphs ease the training
of neural networks with gradient descent algorithm making them many times
faster than traditional implementation of neural networks.
Computational graphs have also found applications in weather forecasting
by reducing the associated computation time. Its strength is fast computation
of derivatives. It is known also by a different name of “reverse-mode
differentiation.”
Beyond its use in deep learning, backpropagation is a powerful
computational tool in many other areas like weather forecasting and analysis
of numerical stability. In many ways, computational graph theory is similar
with logic gate operations in digital circuits where dedicated logic operations
are undertaken with logic gates such as AND, OR, NOR and NAND oper-
ations in the implementation of many binary operations. While the use of
logic gates lead to complex systems such as multiplexers, adders, multipliers
and more complex digital circuits, computational graphs have found their way
into deep learning operations involving derivatives of real numbers, additions,
scaling and multiplications of real numbers by simplifying the operations.
93
(C) 2020 River Publishers Denmark. ISBN: 978-87-7022-096-5 (Hardback) 978-87-7022-095-8 (Ebook)
Johnson Agbinya (Teaching Notes): Applied Data Analytics Principles & Applications
b
f c
a
Figure 6.1
x u v y
Figure 6.2
(C) 2020 River Publishers Denmark. ISBN: 978-87-7022-096-5 (Hardback) 978-87-7022-095-8 (Ebook)
Johnson Agbinya (Teaching Notes): Applied Data Analytics Principles & Applications
Consider the case where f is the operation of addition (+). The result c is
then given by the expression
c = (a + b)
when the operation is multiplication (x), the result is also given by the
expression.
c = (a × b)
Since f is given as a general operator, we may use any operator in the diagram
and write an equivalent expression for c.
b
f c
a
Figure 6.3
(C) 2020 River Publishers Denmark. ISBN: 978-87-7022-096-5 (Hardback) 978-87-7022-095-8 (Ebook)
Johnson Agbinya (Teaching Notes): Applied Data Analytics Principles & Applications
y = (a + b) × (b − 3) = c × d
(6.3)
c = (a + b); d = (b − 3)
(C) 2020 River Publishers Denmark. ISBN: 978-87-7022-096-5 (Hardback) 978-87-7022-095-8 (Ebook)
Johnson Agbinya (Teaching Notes): Applied Data Analytics Principles & Applications
c d
-3
a b
c d
-3
a bb
Figure 6.7 Computation of partial derivatives.
(C) 2020 River Publishers Denmark. ISBN: 978-87-7022-096-5 (Hardback) 978-87-7022-095-8 (Ebook)
Johnson Agbinya (Teaching Notes): Applied Data Analytics Principles & Applications
g h
x y z
dz ∂z ∂z
= ×
dx ∂y ∂x
Δx → Δy → Δz
Figure 6.8 Linear chain rule.
Δx
x
s Δs Δz
z
y Δy
(C) 2020 River Publishers Denmark. ISBN: 978-87-7022-096-5 (Hardback) 978-87-7022-095-8 (Ebook)
Johnson Agbinya (Teaching Notes): Applied Data Analytics Principles & Applications
x1
s X2 z Δs Δz
XN
The general case is more suited to deep learning situations where there are
many stages in the neural network and many branches are also involved.
(C) 2020 River Publishers Denmark. ISBN: 978-87-7022-096-5 (Hardback) 978-87-7022-095-8 (Ebook)
Johnson Agbinya (Teaching Notes): Applied Data Analytics Principles & Applications
K2 (b − a)3
|E| ≤ .
12N 2
K2 is the value of the second derivative of the function f (x). This sets the
bound on the error in the integration value obtained by using the trapezoidal
rule for the function. Thus, once the choice of N is made, an error bound
has been set for the result of the integration. This error may be reduced by
changing the value of N, the number of terms in the summation. Figure 6.11
shows how to compute an integral using the Trapezoidal rule.
(C) 2020 River Publishers Denmark. ISBN: 978-87-7022-096-5 (Hardback) 978-87-7022-095-8 (Ebook)
Johnson Agbinya (Teaching Notes): Applied Data Analytics Principles & Applications
x
1
f
+
f
+
f
+
x
1
(N /2)−1
∆x 4∆x X
≈ [f (x0 ) + f (xN )] + f (x2i+1 )
3 3
i=1
(N /2)−1
2∆x X
+ f (x2i ) (6.11)
3
i=1
b−a
so that ∆x = N ;xi = a + i∆x. Therefore, the computational graph for
this integration method can be easily drawn by first computing the values of
the function at N + 1 locations starting from zero to N in ∆x discrete steps.
Just how big N is will be determined by some error bound which has been
derived to be traditionally
K4 (b − a)5
|E| ≤
180N 4
K4 is the value of the fourth derivative of the function f (x). This sets the
bound on the error in the integration value obtained by using the Simpson
rule for the function. Once the choice of N is made, an error bound has been
(C) 2020 River Publishers Denmark. ISBN: 978-87-7022-096-5 (Hardback) 978-87-7022-095-8 (Ebook)
Johnson Agbinya (Teaching Notes): Applied Data Analytics Principles & Applications
set for the result of the integration. This error may be reduced by changing
the value of N, the number of terms in the summation.
Exercise: Draw the computational graph for the Simpson Rule for integrating
a function.
X Y Z
(C) 2020 River Publishers Denmark. ISBN: 978-87-7022-096-5 (Hardback) 978-87-7022-095-8 (Ebook)
Johnson Agbinya (Teaching Notes): Applied Data Analytics Principles & Applications
(C) 2020 River Publishers Denmark. ISBN: 978-87-7022-096-5 (Hardback) 978-87-7022-095-8 (Ebook)
Johnson Agbinya (Teaching Notes): Applied Data Analytics Principles & Applications
(C) 2020 River Publishers Denmark. ISBN: 978-87-7022-096-5 (Hardback) 978-87-7022-095-8 (Ebook)