neural.py 815 B

123456789101112131415161718192021222324252627
  1. # Store a neuronal network
  2. import numpy as np
  3. class Network():
  4. """
  5. Structure holding neural network attributes
  6. """
  7. def __init__(self, activationFunction, activationDerivative, hiddenLength = 30):
  8. """
  9. activationFunction : the ceil function to apply on network outputs
  10. activationDerivative : the derivative function of the activationFunction
  11. hiddenLength : number of neurons in the hidden layer
  12. """
  13. self.inputLength = 784
  14. self.hiddenLength = hiddenLength
  15. self.outputLength = 10
  16. self.activationFunction = activationFunction
  17. self.activationDerivative = activationDerivative
  18. self.layer1 = np.zeros((self.hiddenLength, self.inputLength))
  19. self.bias1 = np.zeros(self.hiddenLength)
  20. self.layer2 = np.zeros((self.outputLength, self.hiddenLength))
  21. self.bias2 = np.zeros(self.outputLength)