Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MCPNeuron(object):
- """McCollough Neuron implementation.
- Parameters
- __________
- input : List of input objects
- threshold : int
- When the input aggregation reaches this value, the output changes to a 1
- Attributes
- ----------
- excitiations : int
- Total number of excitation states detected.
- """
- def __init__(self, inputs, threshold):
- self.inputs = inputs
- self.threshold = threshold
- def activate(self):
- """ Run the neuron with the list of inputs.
- Return
- ------
- 0 if thehold not reached, 1 otherwise.
- """
- total = 0
- # Build up the total signals from excitators and inhibitators
- for trigger in self.inputs:
- if trigger.excitatory:
- total += trigger.val
- else:
- if trigger.val:
- return 0
- # Has the total gone over the threhold and set off the neuron?
- if total >= self.threshold:
- return 1
- else:
- return 0
Add Comment
Please, Sign In to add comment