Description Details Methods Examples
R6 class representing a computational graph
R6 class representing a computational graph
This objects are created by the '.modello' session
object that links them to the corresponding graph
in the FORTRAN environment.
new()
Initialisation method for reference object of class 'graph'
.graph$new(name)
name
graph
name
finalize()
Awares if a reference object is remove when
when stil referring to an existing graph
.graph$finalize()
name()
Returns the graph
name
.graph$name()
Returns the graph
name
id()
Returns the graph
id
(i.e. position within the GRAPHS_
array)
.graph$id()
Returns the graph
id
pop()
Pop (removes) the graph
from the
GRAPHS_
array.
.graph$pop()
Returns invisible self
\donttest{ modello.init(10, 10, 10, 10) g = graph.open() graph.close() g$is.linked() # TRUE g$pop() g$is.linked() # FALSE modello.close() }
is.linked()
Checks that the reference object is linked to
a graph
.graph$is.linked()
Retursn TRUE if is linked, FALSE otherwise
\donttest{ modello.init(10, 10, 10, 10) g = graph.open() graph.close() g$is.linked() # TRUE g$pop() g$is.linked() # FALSE modello.close() }
op()
Applies all the operators for the nodes in the
graph
.graph$op()
Returns invisible self
\donttest{ modello.init(10, 10, 10, 10) x1 = number(1) x2 = number(3) x3 = number(2) g = graph.open() y = log((x1 + x3)**x2) graph.close() print(y$v) x1$v = 2 g$op() print(y$v) y$dv = 1 g$bw() print(x1$dv) print(x2$dv) print(x3$dv) modello.close() }
bw.zero()
Resest the derivative values for the nodes in the graph
accoriding to the backward differentiation schema.
.graph$bw.zero()
Returns invisible self
bw()
Applies all the backward differentiation operators for
the nodes in the graph
.graph$bw()
Returns invisible self
\donttest{ modello.init(10, 10, 10, 10) x1 = number(1) x2 = number(3) x3 = number(2) g = graph.open() y = log((x1 + x3)**x2) graph.close() print(y$v) x1$v = 2 g$op() print(y$v) y$dv = 1 g$bw() print(x1$dv) print(x2$dv) print(x3$dv) modello.close() }
print()
Prints a representation of the graph
.graph$print()
clone()
The objects of this class are cloneable with this method.
.graph$clone(deep = FALSE)
deep
Whether to make a deep clone.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | ## ------------------------------------------------
## Method `.graph$pop`
## ------------------------------------------------
modello.init(10, 10, 10, 10)
g = graph.open()
graph.close()
g$is.linked() # TRUE
g$pop()
g$is.linked() # FALSE
modello.close()
## ------------------------------------------------
## Method `.graph$is.linked`
## ------------------------------------------------
modello.init(10, 10, 10, 10)
g = graph.open()
graph.close()
g$is.linked() # TRUE
g$pop()
g$is.linked() # FALSE
modello.close()
## ------------------------------------------------
## Method `.graph$op`
## ------------------------------------------------
modello.init(10, 10, 10, 10)
x1 = number(1)
x2 = number(3)
x3 = number(2)
g = graph.open()
y = log((x1 + x3)**x2)
graph.close()
print(y$v)
x1$v = 2
g$op()
print(y$v)
y$dv = 1
g$bw()
print(x1$dv)
print(x2$dv)
print(x3$dv)
modello.close()
## ------------------------------------------------
## Method `.graph$bw`
## ------------------------------------------------
modello.init(10, 10, 10, 10)
x1 = number(1)
x2 = number(3)
x3 = number(2)
g = graph.open()
y = log((x1 + x3)**x2)
graph.close()
print(y$v)
x1$v = 2
g$op()
print(y$v)
y$dv = 1
g$bw()
print(x1$dv)
print(x2$dv)
print(x3$dv)
modello.close()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.