我看不到问题:A,W和b都是已初始化的数组。 np.dot()可在另一个笔记本中使用。我敢肯定这是微不足道的,任何帮助将不胜感激。
def linear_forward(A, W, b):
"""
Implement the linear part of a layer's forward propagation.
Arguments:
A -- activations from previous layer (or input data): (size of previous
layer, number of examples)
W -- weights matrix: numpy array of shape (size of current layer, size of
previous layer)
b -- bias vector, numpy array of shape (size of the current layer, 1)
Returns:
Z -- the input of the activation function, also called pre-activation
parameter
cache -- a python dictionary containing "A", "W" and "b" ; stored for
computing the backward pass efficiently
"""
print(type(W), type(A), type(b))
Z = np.sum(np.dot(W,A), b)
assert(Z.shape == (W.shape[0], A.shape[1]))
cache = (A, W, b)
return Z, cache
Z, linear_cache = linear_forward(train_X, parameters["W1"], parameters["b1"])
<class 'numpy.ndarray'> <class 'numpy.ndarray'> <class 'numpy.ndarray'>
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-46-acc623b98d4c> in <module>
----> 1 Z, linear_cache = linear_forward(train_X, parameters["W1"], parameters["b1"])
<ipython-input-45-82f7e782daed> in linear_forward(A, W, b)
14
15 print(type(W), type(A), type(b))
---> 16 Z = np.sum(np.dot(W,A), b)
17
18 assert(Z.shape == (W.shape[0], A.shape[1]))
TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'