overflow
The logistic sigmoid function tends to overflow in NumPy with increasing signal power. Try adding the following line of code:
np.clip( signal, -500, 500 )
This will limit the values ββin the NumPy matrices within the specified interval. This, in turn, will prevent overflow of precision in the sigmoid function.
>>> arr array([[-900, -600, -300], [ 0, 300, 600]]) >>> np.clip( arr, -500, 500) array([[-500, -500, -300], [ 0, 300, 500]])
Implementation
This is a snippet that I use in my projects:
def sigmoid_function( signal ):
Why is the sigmoid function overflowing?
As learning progresses, the network improves its accuracy. As this accuracy approaches perfection, the sigmoidal signal will approach 1 from below or 0 from above. For example: 0.99999999999 ... or 0.00000000000000001 ...
Because NumPy is focused on performing high-precision numerical operations, it will try to maintain the highest possible accuracy and thus cause an overflow error. Note. This error message can be ignored by setting:
np.seterr( over='ignore' )
jorgenkg
source share