neon icon indicating copy to clipboard operation
neon copied to clipboard

Sigmoid function in CPU backend is numerically unstable

Open miketout opened this issue 7 years ago • 0 comments

To prevent crashing on a regular basis, I've had to add the following file to our project. I would really prefer not to do this:

from scipy.special import expit

def fix_logistic_cpu(be): try: from neon.backends.nervanacpu import numpy_call_dict_cpu assert not numpy_call_dict_cpu.get('sig', None) is None numpy_call_dict_cpu['sig'] = lambda left: expit(left) except Exception as e: from neon.backends.nervanacpu import numpy_call_dict assert not numpy_call_dict.get('sig', None) is None numpy_call_dict['sig'] = lambda left: expit(left)

def fix_logistic(be): fix_logistic_cpu(be)

miketout avatar Dec 04 '17 05:12 miketout