# NOT RUN {
# 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")
# }
Run the code above in your browser using DataLab