【发布时间】:2020-06-29 23:29:08
【问题描述】:
为了快速计算,我必须在 Numpy 中实现我的 sigmoid 函数,这是下面的代码
def sigmoid(Z):
"""
Implements the sigmoid activation in bumpy
Arguments:
Z -- numpy array of any shape
Returns:
A -- output of sigmoid(z), same shape as Z
cache -- returns Z, useful during backpropagation
"""
cache=Z
print(type(Z))
print(Z)
A=1/(1+(np.exp((-Z))))
return A, cache
还有一些相关信息:
Z=(np.matmul(W,A)+b)
Z的类型是:
<class 'numpy.ndarray'>
遗憾的是,我得到了一个:“一元操作数类型错误 -: 'tuple'” 我试图在没有任何运气的情况下解决这个问题。我感谢任何建议。 最好的
【问题讨论】:
-
Z显然是一个元组,而不是一个 numpy 数组或其他类似数组的对象。 -
你能提供更多的代码来表明输入到函数中的内容吗?