cg_operator {cgraph} | R Documentation |
Add an operation node to the active graph.
cg_operator(fun, inputs, name = NULL)
fun |
cg_function object, function evaluated by the node. |
inputs |
list, the nodes that are consumed by the operation. |
name |
character scalar, name of the node (optional). In case argument |
cg_node object.
Any objects that are supplied to argument inputs
that are not cg_node objects are implicitly converted to cg_constant objects.
Ron Triepels
# Initialize a computational graph x <- cg_graph() # Create a custom negation function f <- cg_function( def = function(x) -x, grads = list(function(x, val, grad) -grad) ) # Add a an operator with the negation function to the graph. a <- cg_operator(f, list(10), name = "a")