value R6 class
value R6 class
Details
Represents a node in the computational graph with automatic differentiation. Each value object holds data as a matrix, gradient as a matrix of the same dimensions, a backward function, previous nodes, and an optional label.
All data in femtograd uses matrix representation:
Scalars are 1x1 matrices
Column vectors are n x 1 matrices
Row vectors are 1 x n matrices
Matrices are m x n matrices
This ensures consistent behavior for get_data(), grad(), and hessian().
Public fields
dataNumeric matrix containing the value
gradGradient matrix (same dimensions as data), initially zeros
backward_fnA function that performs the backward pass (gradient computation)
prevA list of previous nodes in the computational graph
labelOptional character label for debugging (default: "")