NumPyCNN icon indicating copy to clipboard operation
NumPyCNN copied to clipboard

sigmoid(sop) function not numerically safe

Open jtlareau opened this issue 2 years ago • 1 comments

The current implementation of the sigmoid() function can get a RuntimeWarning overflow in cnn.py at line 29 numpy.exp(): "return 1.0 / (1 + numpy.exp(-1 * sop))" To avoid/correct the overflow, use: "return numpy.exp(-numpy.logaddexp(0, -sop))"

jtlareau avatar Oct 08 '22 00:10 jtlareau

It is just a warning and NumPy is able to handle the situation. It happens when a large number like 1234.1234 is fed to the numpy.exp() function. This does not affect the result.

ahmedfgad avatar Feb 19 '23 01:02 ahmedfgad