Description Usage Arguments Value Note Author(s) Examples
Add an operation node to the active graph.
1 | 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 coerced to cg_constant objects.
The elements of argument input
can be named to control how the arguments of the function provided to argument fun
are machted when the function is evaluated. In case no names are provided, arguments are matched positionally.
Ron Triepels
1 2 3 4 5 6 7 8 9 10 11 | # Initialize a computational graph
graph <- 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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.