Learn R Programming

cgraph (version 6.0.1)

cg_graph_forward: Forward Pass

Description

Perform a forward pass to evaluate a given target node in a graph.

Usage

cg_graph_forward(graph, target)

Arguments

graph

cg_graph object, graph that is evaluated.

target

cg_node object, node in the graph that is evaluated. Alternatively, argument target can be a character scalar denoting the name of the node in the graph that is evaluated.

Value

None.

Examples

Run this code
# 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