Allows to create, evaluate, and differentiate computational graphs in R. A computational graph is a graph representation of a multivariate function decomposed by its (elementary) operations. Nodes in the graph represent arrays while edges represent dependencies among the arrays. An advantage of expressing a function as a computational graph is that this enables to differentiate the function by automatic differentiation. The 'cgraph' package supports various operations including basic arithmetic, trigonometry operations, and linear algebra operations. It differentiates computational graphs by reverse automatic differentiation. The flexible architecture of the package makes it applicable to solve a variety of problems including local sensitivity analysis, gradient-based optimization, and machine learning.
Bug fixes:
rchk
.Comments:
v
followed by the node id.cg_node
object for efficiency reasons.index
of function cg_graph_gradients
can now also be NULL
to differentiate nodes element-wise. This is now also the default behavior.Bug fixes:
cg_graph_run
and cg_graph_gradients
respectively.bsum
now prints a correct error message when argument block_size
is not a numerical scalar.Bug fixes:
cgraph
on R versions before 3.5.cg_session_set_graph
no longer prints NULL
to the console when the active graph is changed.cg_sigmoid
now works correctly when argument x
is a logical or integer vector or array.Comments:
cgraph
is removed. To create a computational graph, use function cg_graph
instead.get_parms
and add_parms
are no longer available.active
is removed. The active graph can now be retrieved and changed by function cg_session_graph
and cg_session_set_graph
respectively.adj_mat
is removed.print
is removed.const
, input
, parm
, and opr
have been renamed to cg_constant
, cg_input
, cg_parameter
, and cg_operator
respectively.val
and set
are removed. The value of a constant or parameter node can be retrieved or changed directly by calling x$value
where x
is the environment of a cg_node
object.run
and gradients
have been renamed to cg_graph_run
and cg_graph_gradients
respectively.Features:
cg_function
object which can be linked to an operator. This significantly reduces the size of a cg_graph
object.Documentation:
R6
has been removed from the Imports
section in the package description.Rgraphviz
has been removed from the Suggests
section in the package description.Bug fixes:
cg_node
environment rather than its value when calling cg_graph_run
and cg_graph_gradients
.cg_graph_run
and cg_graph_gradients
on a cg_graph
object which contains nodes with an invalid id.Bug fixes:
Comments:
cg.matmul
is now named cg_matmul
. The same rule applies to class names. For example, class cg.node
is now named cg_node
.name
is removed. Names for nodes are now generated internally in the C-API.approx.gradients
is removed. A simliar function is still available as cgraph:::approx_grad
in the package namespace. However, it should be noted that this function is not well-optimized and should only be used for testing purposes.print
on a cg_node
object no longer prints the value of the node. Use function val
to evaluate a node.Features:
library
which can be used to specify which function library the graph uses.val
and set
to retrieve or set the value of a node respectively.cg_mean
now calls the base mean
function.cg_crossprod
and cg_tcrossprod
now allow argument y
to be missing (similarly as the corresponding base functions).dim
of operator cg_reshape
now expects an cg_node
object instead of an integer scalar or vector that holds the new array dimensions.Bug fixes:
Comments:
+
or -
will have S3 overloaded methods.Bug fixes:
sigmoid
now correctly handles numerical underflow.cg.pmax
and cg.pmin
are now correctly differentiated when argument x
and y
are both arrays.Features:
!
, ==
, !=
, <
, >
, <=
, and >=
.Documentation:
const
, input
, parm
, and opr
now correctly states that argument name
must be a character scalar (not a symbol).Bug fixes:
run
, gradients
, and approx.grad
no longer cause an infinite loop when member values
of a cgraph
object is supplied to the values
argument of the functions.gradients
which caused the R session to crash unexpectedly.approx.grad
now checks whether node x
and y
evaluate to a numeric vector or array.approx.grad
no longer changes the parent environment of argument values
when the argument is an environment.Bug fixes:
run
and gradients
no longer change the parent environment of argument values
when the argument is an environment.name
no longer generates a name that indicates the node type for performance reasons. Instead, it simply generates the name 'node' followed by the number of nodes that have been added to the graph.rchk
.Comments:
Features:
sinh
and cosh
.asinh
and acosh
.nodes
of a cgraph
object are now named to allow more convenient access to the symbols of the nodes in a graph.options(cg.autorun = FALSE)
.Documentation:
Bug fixes:
cgraph
object instead of trying to coerce the object to a valid object.opr
now ignores argument grads
when its elements are not properly named.run
now checks whether each node evaluates to a numeric vector or array.gradients
now checks whether the node supplied to argument name
evaluates to a numeric vector or array.get.parms
and add.parms
now correctly call the underlying C-API.Comments:
Documentation:
cgraph
object and their corresponding wrapper functions.Comments: