map([$this, '_activate']); } /** * Calculate the derivative of the activation. * * @internal * * @param Matrix $input * @param Matrix $output * @return Matrix */ public function differentiate(Matrix $input, Matrix $output) : Matrix { return $output->map([$this, '_differentiate']); } /** * @internal * * @param float $input * @return float */ public function _activate(float $input) : float { return $input > 0.0 ? self::SCALE * $input : self::BETA * (exp($input) - 1.0); } /** * @internal * * @param float $output * @return float */ public function _differentiate(float $output) : float { return $output > 0.0 ? self::SCALE : self::SCALE * ($output + self::ALPHA); } /** * Return the string representation of the object. * * @internal * * @return string */ public function __toString() : string { return 'SELU'; } }