Skip to content
Permalink
0.0.1-alpha
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
29 lines (26 sloc) 626 Bytes
<?php
namespace Rubix\Engine\NeuralNetwork\ActivationFunctions;
class HyperbolicTangent implements ActivationFunction
{
/**
* Compute the output value.
*
* @param float $value
* @return float
*/
public function compute(float $value) : float
{
return tanh($value);
}
/**
* Calculate the partial derivative with respect to the computed output.
*
* @param float $value
* @param float $computed
* @return float
*/
public function differentiate(float $value, float $computed) : float
{
return 1 - ($computed ** 2);
}
}