Exemplo n.º 1
0
    def bidiSynapseFired(self, BidiSynapse):
        lockOwner = BidiSynapse.lockOwner

        if lockOwner is self:
            self.numberOfOutputBidiSynapsesFired += 1
            BidiSynapse.releaseLock()

        else:
            # Let`s find out to which neuron/direction the firing
            # takes place :-)
            neuron = None
            if lockOwner is BidiSynapse.startPoint:
                neuron = BidiSynapse.endPoint
                numberOfWhatSynapses = self.numberOfInputBidiSynapses
                numberOfWhatSynapsesFired = self.numberOfInputBidiSynapsesFired
                #neuron.numberOfInputBidiSynapsesFired += 1
            else:
                neuron = lockOwner
                numberOfWhatSynapses = self.numberOfOutputBidiSynapses
                numberOfWhatSynapsesFired = self.numberOfOutputBidiSynapsesFired
                #neuron.numberOfOutputBidiSynapsesFired += 1

            BidiSynapse.acquireLock(self)
            self.numberOfSynapsesFired += 1

            if numberOfWhatSynapsesFired <= 1:
                prev = self.get_property("value")
                self.set_property("value", prev + BidiSynapse.getValue())

            # Activate the neuron if all the input synapses have fired!
            if numberOfWhatSynapsesFired == numberOfWhatSynapses:
                val = StepActivation.sigmoid(self.get_property("value"))
                self.set_property("value", val)

                self.emit("activation")
Exemplo n.º 2
0
 def bidiSynapseFired (self, BidiSynapse):
     lockOwner = BidiSynapse.lockOwner
     
     if lockOwner is self:
         self.numberOfOutputBidiSynapsesFired += 1
         BidiSynapse.releaseLock ()
         
     else:
         # Let`s find out to which neuron/direction the firing
         # takes place :-)
         neuron = None
         if lockOwner is BidiSynapse.startPoint:
             neuron = BidiSynapse.endPoint
             numberOfWhatSynapses = self.numberOfInputBidiSynapses
             numberOfWhatSynapsesFired = self.numberOfInputBidiSynapsesFired
             #neuron.numberOfInputBidiSynapsesFired += 1
         else:
             neuron = lockOwner
             numberOfWhatSynapses = self.numberOfOutputBidiSynapses
             numberOfWhatSynapsesFired = self.numberOfOutputBidiSynapsesFired
             #neuron.numberOfOutputBidiSynapsesFired += 1
         
         BidiSynapse.acquireLock (self)                
         self.numberOfSynapsesFired +=1
         
         if numberOfWhatSynapsesFired <= 1:
             prev = self.get_property ("value")
             self.set_property ("value", prev + BidiSynapse.getValue ())
         
         # Activate the neuron if all the input synapses have fired!
         if numberOfWhatSynapsesFired == numberOfWhatSynapses:
             val = StepActivation.sigmoid (self.get_property ("value"))
             self.set_property ("value", val)
             
             self.emit ("activation")
Exemplo n.º 3
0
 def synapseFired (self, Synapse):
     self.numberOfSynapsesFired += 1
     
     if self.numberOfSynapsesFired <= self.numberOfInputs:
         prev = self.get_property ("value")
         self.set_property ("value", prev + Synapse.getValue ())
     
     # When _all_ incoming synapses have fired, activate the neuron!
     if self.numberOfSynapsesFired == self.numberOfInputs:
         val = StepActivation.sigmoid (self.get_property ("value"))
         self.set_property ("value", val)
         
         self.emit ("activation")