# NOT RUN {
# Initialize a computational graph
graph <- cg_graph()
# Add an input
a <- cg_input(name = "a")
# Square the input (i.e. b = a^2)
b <- cg_pow(a, 2, name = "b")
# Set a equal to 2
a$value <- 2
# Perform forward pass
cg_graph_forward(graph, b)
# Retrieve the value of b
b$value
# }
Run the code above in your browser using DataLab