Overview
- namespace: Rindow\NeuralNetworks\Builder
- classname: Gradient
Creation of objects with automatic differentiation function
gradient utilities
- Variable : Create variable
- GradientTape : Tape for recording calculation graphs
- GraphFunction : Creating a differentiable function
- isUndetermined: Check variable.
Differentiable functions
Examples
use Rindow\Math\Matrix\MatrixOperator;
use Rindow\NeuralNetworks\Builder\NeuralNetworks;
$mo = new MatrixOperator();
$nn = new NeuralNetworks($mo);
$g = $nn->gradient();
$a = $g->Variable([1,2]);
$b = $g->Variable([2,3]);
$c = $nn->with($tape=$g->GradientTape(),function() use ($g,$a,$b) {
return $g->mul($a,$b);
});
[$da,$db] = $tape->gradient($c,[$a,$b]);
echo $mo->toString($c)."\n";
echo $mo->toString($da)."\n";
echo $mo->toString($db)."\n";
# [2,6]
# [2,3]
# [1,2]