且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

numpy:TypeError中的错误:只能将长度为1的数组转换为Python标量

更新时间:2022-03-21 18:41:30

当采用数组或其他不想使用Python数学库的指数时,请改用NumPy库:

When you are taking the exponent of an array or anything else you don't want to use Python's math library, use NumPy library instead:

import numpy as np
def sigmoid(inX):
    r = 1.0/(1+ np.exp(-inX))
    return r