title: Why do we multiply calls to numpy.random.random by numbers and subtract numbers?
body: <p>I found this snippet of code in an article about backpropagation and I got confused on how exactly it works. The article says the following</p>
  
  <p>"This is our weight matrix for this neural network. It's called "syn0" to imply "synapse zero". Since we only have 2 layers (input and output), we only need one matrix of weights to connect them. Its dimension is (3,1) because we have 3 inputs and 1 output."</p>
  
  <p>I want to specify that by input the author is referring to array "X" and output refers to array "Y".</p>
  
  <p>My first question is why does the article claim we have only 3 inputs. A glance at the code reveals that our array, X, has size 4. Am I just misunderstanding something?</p>
  
  <p>My second question is why are multiplying the call to np.random.random() by 2?</p>
  
  <p>Thanks for the help!</p>
  
  <pre><code>import numpy as np    
  
  X = np.array([ [0,0,1],
                 [0,1,1],
                 [1,0,1],
                 [1,1,1] ])
  
  y = np.array([[0,0,1,1]]).T  
  
  # initialize weights randomly with mean 0
  syn0 = 2*np.random.random((3,1)) - 1
  </code></pre>