Most references I find say that the activation function used in nnet
is 'usually' a logistic function. But in the case that I would like to test the performance of the trained neural network from nnet, it is necessary to know the exact activation function used.
1 Answer
This is the implemented function (extracted from the C-sources; filennet.c
, lines 156-165):
static double
sigmoid(double sum)
{
if (sum < -15.0)
return (0.0);
else if (sum > 15.0)
return (1.0);
else
return (1.0 / (1.0 + exp(-sum)));
}
-
$\begingroup$ Wonder why there is -15/15 limit, it is because it is faster to check for this condition than calculate
exp(15)
? $\endgroup$ Feb 27, 2015 at 21:32 -
$\begingroup$
1 / (1 + exp(- (15)))
is approx 0.999999694 and1 / (1 + exp(-(-15)))
is approx. 0.000000306 so they just choose to take the error. 15 seems pretty arbitrary, but fair. $\endgroup$– JonNov 18, 2016 at 3:02