Learn R Programming

ggmlR (version 0.8.4)

ggml_graph_reset: Reset Graph (for backpropagation)

Description

Zeroes every gradient in the graph and seeds the loss node's own gradient with 1 -- the value the chain rule starts from. Call this after ggml_build_backward_expand and before ggml_graph_compute: without it every gradient computes as zero, since the backward pass multiplies through a seed that was never set.

Usage

ggml_graph_reset(graph)

Value

No return value, called for side effects

Arguments

graph

Graph object with gradients allocated

Details

Requires a graph built by ggml_build_forward_expand_grads; an inference-only graph has no gradients to reset and is rejected.

See Also

ggml_build_backward_expand, ggml_build_forward_expand_grads