a simple neural network

make a basic neural network which can predict something useful, like predicting the digits in the mnist database of handwritten digits.

  • Input: each digit is 28*28 pixels, so 784 pixels in total
  • Hidden layer: tinker around
  • Output layer: 10 outputs, to indicate one of the ten possible numbers

In [22]:
import numpy as np

class NeuralNetwork(object):
    
    def __init__(self):
        self.input_layer = 28*28
        self.hidden_layer = 20
        self.output_layer = 10
        
        self.weigths_input_hidden = np.random.randn(self.input_layer,self.hidden_layer)
        self.weights_hidden_output = np.random.randn(self.hidden_layer,self.output_layer)
        self.biases_input_hidden = np.random.randn(self.hidden_layer)
        self.biases_hidden_output = np.random.randn(self.output_layer)
    
    def sigmoid(x):
        return 1.0/(1.0+np.exp(-x))

n = NeuralNetwork()
n.weigths_input_hidden.shape, n.weights_hidden_output.shape


Out[22]:
((784, 20), (20, 10))

In [25]:
n.sigmoid(1.1)


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-25-0cde937b030e> in <module>()
----> 1 n.sigmoid(1.1)

TypeError: sigmoid() takes 1 positional argument but 2 were given

In [ ]: