我正在尝试使用 predict() 函数使用 X_trainT 和 X_testT 预测测试和训练数据的输出。我收到以下列出的错误 -
yPredTrain = predict(X_trainT, parameters)
yPredTest = predict(X_testT, parameters) # This function is throwing the error
预测功能
def predict(X, parameters):
W = parameters["W"]
b = parameters["b"]
W = W.reshape(X.shape[0], 1)
#Z = np.dot(W.T,X) + b
Z = np.dot(W.T,X) + b
Y = np.array([1 if y > 0.5 else 0 for y in sigmoid(Z[0])]).reshape(1,len(Z[0]))
#Y = np.array([1 if y > 0.5 else 0 for y in Z[0]]).reshape(1,len(Z[0]))
return Y
错误
ValueError Traceback (most recent call last)
<ipython-input-20-a5c2d40ef32d> in <module>()
1 yPredTrain = predict(X_trainT, parameters)
----> 2 yPredTest = predict(X_testT, parameters)
<ipython-input-9-dfb2f70a0c07> in predict(X, parameters)
4 W = W.reshape(X.shape[0], 1)
5 #Z = np.dot(W.T,X) + b
----> 6 Z = np.dot(W.T,X) + b
7 Y = np.array([1 if y > 0.5 else 0 for y in sigmoid(Z[0])]).reshape(1,len(Z[0]))
8 #Y = np.array([1 if y > 0.5 else 0 for y in Z[0]]).reshape(1,len(Z[0]))
ValueError: operands could not be broadcast together with shapes (1,143) (426,) ```