Guest User

Untitled

a guest
Dec 11th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. class MCPNeuron(object):
  2. """McCollough Neuron implementation.
  3.  
  4. Parameters
  5. __________
  6. input : List of input objects
  7. threshold : int
  8. When the input aggregation reaches this value, the output changes to a 1
  9.  
  10. Attributes
  11. ----------
  12. excitiations : int
  13. Total number of excitation states detected.
  14.  
  15. """
  16.  
  17. def __init__(self, inputs, threshold):
  18. self.inputs = inputs
  19. self.threshold = threshold
  20.  
  21. def activate(self):
  22. """ Run the neuron with the list of inputs.
  23.  
  24. Return
  25. ------
  26. 0 if thehold not reached, 1 otherwise.
  27. """
  28.  
  29. total = 0
  30.  
  31. # Build up the total signals from excitators and inhibitators
  32. for trigger in self.inputs:
  33. if trigger.excitatory:
  34. total += trigger.val
  35. else:
  36. if trigger.val:
  37. return 0
  38.  
  39. # Has the total gone over the threhold and set off the neuron?
  40. if total >= self.threshold:
  41. return 1
  42. else:
  43. return 0
Add Comment
Please, Sign In to add comment