以下是sigmoid函数的标准写法,但是如果x很大或导致函数exp(-x)溢出

def logistic_function(x):
#     x = np.float64(x)
    return 1.0 / (1.0 + np.exp(-x))

安全的替代写法如下:

def logistic_function(x):
    return .5 * (1 + np.tanh(.5 * x))

 

相关文章:

  • 2022-12-23
  • 2022-01-09
  • 2022-12-23
  • 2021-07-11
  • 2021-12-27
  • 2021-05-27
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2021-08-23
  • 2022-12-23
  • 2021-08-04
相关资源
相似解决方案