exp

  • namespace: Rindow\NeuralNetworks\Gradient\Func
  • classname: Exp

Differentiable exponential function.

Methods

add

$builer->exp(
    Variable|NDArray $a
) : Variable

Create and execute the function in the builder method

Arguments

  • a: The argument is Variable or NDArray. Implicitly create Variable for NDArray.
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]);
$c = $nn->with($tape=$g->GradientTape(),function() use ($g,$a) {
    return $g->exp($a);
});
$da = $tape->gradient($c,$a);
echo $mo->toString($c, '%6.3f')."\n";
echo $mo->toString($da,'%6.3f')."\n";

# [ 2.718, 7.389]
# [ 2.718, 7.389]