title: How to get predicted values based on weights and bias in python
body: <p><strong>I am trying predict the output of test and train data using X_trainT and X_testT using predict() function. I'm getting below listed error -</strong></p>
  <pre><code>yPredTrain = predict(X_trainT, parameters)   
  yPredTest = predict(X_testT, parameters)    # This function is throwing the error
  </code></pre>
  <hr />
  <h1>Predict function</h1>
  <pre><code>def predict(X, parameters):
    W = parameters[&quot;W&quot;]
    b = parameters[&quot;b&quot;]
    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 &gt; 0.5 else 0 for y in sigmoid(Z[0])]).reshape(1,len(Z[0]))
    #Y = np.array([1 if y &gt; 0.5 else 0 for y in Z[0]]).reshape(1,len(Z[0]))
    return Y
  </code></pre>
  <hr />
  <h1>Error</h1>
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-20-a5c2d40ef32d&gt; in &lt;module&gt;()
        1 yPredTrain = predict(X_trainT, parameters)   
  ----&gt; 2 yPredTest = predict(X_testT, parameters)    
  
  &lt;ipython-input-9-dfb2f70a0c07&gt; in predict(X, parameters)
        4   W = W.reshape(X.shape[0], 1)
        5   #Z = np.dot(W.T,X) + b
  ----&gt; 6   Z = np.dot(W.T,X) + b
        7   Y = np.array([1 if y &gt; 0.5 else 0 for y in sigmoid(Z[0])]).reshape(1,len(Z[0]))
        8   #Y = np.array([1 if y &gt; 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,) ```
  </code></pre>