Skip to contents

dL/dx = sum over children of (dL/dy)(dy/dx) in one reverse sweep; fan-out ACCUMULATES. The graph is a named list node -> named list parent -> local partial.

Usage

morie_geron_reverse_mode_autodiff(graph, loss_grad = 1, output = NULL)

Arguments

graph

Named list of named partial-derivative lists.

loss_grad

Seed gradient at the output node.

output

Optional output node name; inferred when unique.

Value

List with gradients, leaf_gradients, order, output.

Examples

g <- list(L = list(a = 2, b = -1), a = list(x = 3), b = list(x = 0.5,
    y = 1))
morie_geron_reverse_mode_autodiff(g, 1)
#> $gradients
#> $gradients$L
#> [1] 1
#> 
#> $gradients$b
#> [1] -1
#> 
#> $gradients$y
#> [1] -1
#> 
#> $gradients$a
#> [1] 2
#> 
#> $gradients$x
#> [1] 5.5
#> 
#> 
#> $leaf_gradients
#> $leaf_gradients$y
#> [1] -1
#> 
#> $leaf_gradients$x
#> [1] 5.5
#> 
#> 
#> $order
#> [1] "L" "b" "y" "a" "x"
#> 
#> $output
#> [1] "L"
#> 
#> $estimate
#> $estimate$y
#> [1] -1
#> 
#> $estimate$x
#> [1] 5.5
#> 
#> 
#> $n
#> [1] 5
#>