def setSynapse(self, axon, dendrite, weight): axon_id = mutil.extractNeuronId(axon) dendrite_id = mutil.extractNeuronId(dendrite) #print 'setting synapse from', axon_id, 'to', dendrite_id, 'with weight', weight mutil.makeDictIfNot(self.synapses_by_dendrite, dendrite_id) mutil.makeDictIfNot(self.synapses_by_axon, axon_id) self.synapses_by_dendrite[dendrite_id][axon_id] = weight self.synapses_by_axon[axon_id][dendrite_id] = weight
def weightAtSynapse(self, axon, dendrite): axon_id = mutil.extractNeuronId(axon) dendrite_id = mutil.extractNeuronId(dendrite) return self.synapses_by_axon[axon_id][dendrite_id]
def getAllSynapsesByAxon(self, axon): neuron_id = mutil.extractNeuronId(axon) if self.synapses_by_axon.has_key(neuron_id): return self.synapses_by_axon[neuron_id] #print 'no synapses found' return {}
def getAllSynapsesByDendrite(self, dendrite): neuron_id = mutil.extractNeuronId(dendrite) if self.synapses_by_dendrite.has_key(neuron_id): return self.synapses_by_dendrite[neuron_id] #print 'no synapses found' return {}
def setErrorAt(self, neuron, error): neuron_id = mutil.extractNeuronId(neuron) if self.neurons.has_key(neuron_id): #print 'setting error at', neuron_id, 'to', error self.neurons[neuron_id].error = error
def getErrorAt(self, neuron): neuron_id = mutil.extractNeuronId(neuron) if self.neurons.has_key(neuron_id): return self.neurons[neuron_id].error
def derivativeOutputAt(self, neuron): neuron_id = mutil.extractNeuronId(neuron) return self.neurons[neuron_id].derivativeOutput()
def outputAt(self, neuron): neuron_id = mutil.extractNeuronId(neuron) return self.neurons[neuron_id].output()