TypeError:无法将sequence乘以'float'numpy类型的nonit

2024-03-29 12:42:52 发布

您现在位置:Python中文网/ 问答频道 /正文

当我将正确维度的numpy数组传递给下面的函数时,我得到一个错误:TypeError:不能将sequence乘以类型为“float”的非int。 see picture
请帮忙。在

def linear_forward(A, W, b):

    print('W.type:', type(W), 'W.shape:', W.shape)
    print('A.type:', type(A), 'A.shape:', A.shape)
    Z = np.dot(W, A) + b

    assert (Z.shape == (W.shape[0], A.shape[1]))
    cache = (A, W, b)

    return Z, cache

数据:sample dataset

W由这里的代码生成(它等于参数['W1']):

^{pr2}$

Tags: 函数numpy类型cachetype错误数组float