Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
29 lines (26 sloc)
637 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Rubix\Engine\NeuralNetwork\ActivationFunctions; | |
class Heaviside implements ActivationFunction | |
{ | |
/** | |
* Compute the output value. | |
* | |
* @param float $value | |
* @return float | |
*/ | |
public function compute(float $value) : float | |
{ | |
return $value >= 0.0 ? 1.0 : 0.0; | |
} | |
/** | |
* 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 $value === 0.0 ? 1.0 : 0.0; | |
} | |
} |