title: AttributeError: object x has no attribute y
body: <p>Out of curiosity I tried to write a basic neural network myself, but I ran into an error when I tried to initialize the object.</p>
  
  <pre><code>class NeuralNet(object):
  
      def __init__(self,layers,activication = "tanh"):
  
          if activication == "sigmoid":
              self.activication = sigmoid
              self.activication_deriv = sigmoid_derivative
  
          elif activication == "tanh":
              self.activication = tanh
              self.activication_deriv = tanh_deriv
  
          """initializing weights with random values
             between -0.25 and 0.25 and also adding bias unit"""
          self.weigths = []
          for i in range(1,len(layers)-1):
              self.weights.append((2*np.random((layers[i - 1] + 1, layers[i] + 1))-1)*0.25)
          self.weights.append((2*np.random.random((layers[i] + 1, layers[i + 1]))-1)*0.25)
  </code></pre>
  
  <p><strong>This is how I tried to initialize it:</strong></p>
  
  <pre><code>nn = NeuralNet([1,2,1],"tanh")
  </code></pre>
  
  <p><strong>The error:</strong></p>
  
  <pre><code>traceback (most recent call last):
    File "/home/a/Documents/LiClipse Workspace/machine_learning/src/sf.py", line 180, in &lt;module&gt;
      single_model(train_set,labels)
    File "/home/a/Documents/LiClipse Workspace/machine_learning/src/sf.py", line 130, in single_model
      nn = NeuralNet([1,2,1],"tanh")
    File "/home/a/Documents/LiClipse Workspace/machine_learning/src/neuralnetwork.py", line 41, in __init__
      self.weights.append((2*np.random((layers[i - 1] + 1, layers[i] + 1))-1)*0.25)
  AttributeError: 'NeuralNet' object has no attribute 'weights'
  </code></pre>
  
  <p>As you can see my Object doesn't have the attribute weights. I am new to object orientation in python, so I'm not sure what I'm doing wrong here. I tried to look into other neural network implementations, and into similar stackoverflow questions, but I was unable to derive the solution from them. </p>