Sigmoid function-activation function

Let's write a sigmoid function in Perl. The sigmoid function is one of the activation functions.

sub sigmoid {
   my ($x) = @_;
  
   my $sigmoid = 1.0 / (1.0 + exp(-$x));
  
   return $sigmoid;
}

my $x = 0.5;
my $sigmoid = sigmoid ($x);

# 0.6224593312018545646389
print "$sigmoid\n";

Derivative of sigmoid function

Please refer to the following article for the derivative of the sigmoid function.

Associated Information