title: How do I fix ValueError: non-broadcastable output operand with shape (2,1) doesn't match the broadcast shape (2,2) error?
body: <p>I am trying to train a neural network but I am stuck at this point where I should get and (2,1) array but the code keeps bringing me a (2,2) array.</p>
  
  <p>Trying to transpose the matrix or making the (1,) array as scalar (v[0]) just didn't work.</p>
  
  <p>This is a sample of the code I am having trouble with:</p>
  
  <pre><code>import numpy as np
  
  a = np.array([[0.3],[-0.1]])
  b = np.zeros(a.shape)
  c=np.array([ 0.5249765])
  d=np.array([ 0.4850045,   0.45512111])
  y = np.array([ 0.4])
  error = y - c 
  f= error * c * (1 - c)
  
  b+=f[0]*d.T
  </code></pre>
  
  <p>The result I was expecing was </p>
  
  <pre><code>b = [-0.0151157 -0.0141844] 
  </code></pre>
  
  <p>but I keep getting</p>
  
  <pre><code>b = [[-0.0151157    -0.0141844]
  [-0.0151157 -0.0141844]]
  </code></pre>