Derivative of tanh function --Derivative of activation function
Let's write the derivative of the tanh function in Perl.
The derivative of the tanh function is used for the inverse mispropagation method.
use strict;
use warnings;
use Math::Trig'tanh';
sub tanh_derivative {
my ($x) = @_;
my $tanh_derivative = 1 --tanh ($x) ** 2;
return $tanh_derivative;
}
my $value1 = 0.5;
my $tanh_derivative1 = tanh_derivative ($value1);
# 0.786447732965927
print "$tanh_derivative1\n";
Perl AI Deep Learning Tutorial