如何在python中基于权重和偏差获得预测值

如何在python中基于权重和偏差获得预测值,python,numpy,machine-learning,train-test-split,bias-neuron,Python,Numpy,Machine Learning,Train Test Split,Bias Neuron,我正在尝试使用X_trainT和X_testT使用predict()函数预测测试和训练数据的输出。下面列出了错误- yPredTrain = predict(X_trainT, parameters) yPredTest = predict(X_testT, parameters) # This function is throwing the error 预测函数 错误 ValueError回溯(最近一次调用) 在() 1 yPredTrain=预测(X_列车,参数) ---

我正在尝试使用X_trainT和X_testT使用predict()函数预测测试和训练数据的输出。下面列出了错误-

yPredTrain = predict(X_trainT, parameters)   
yPredTest = predict(X_testT, parameters)    # This function is throwing the error

预测函数
错误
ValueError回溯(最近一次调用)
在()
1 yPredTrain=预测(X_列车,参数)
---->2 yPredTest=预测(X_testT,参数)
在预测中(X,参数)
4 W=W.重塑(X.形状[0],1)
5#Z=np.dot(W.T,X)+b
---->6z=np.dot(W.T,X)+b
7 Y=np.数组(如果Y>0.5,则为1,否则为0,Y为S形(Z[0]))。重塑(1,len(Z[0]))
8#Y=np.数组([1如果Y>0.5,则为0,对于Z[0]])。重塑(1,len(Z[0]))
ValueError:操作数无法与形状(1143)(426,)一起广播```
看,我很确定这就是问题所在。看,我很确定这就是问题所在。
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,) ```