示例#1
0
文件: ann.py 项目: Hydex/ann
    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
示例#2
0
文件: ann.py 项目: Hydex/ann
    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
示例#3
0
文件: ann.py 项目: Hydex/ann
 def adjustWeights(self):
     new_weights = dict()
     for axon_id in sorted(self.neurons.keys(), reverse=False):
         mutil.makeDictIfNot(new_weights, axon_id)
         for dendrite_id in self.getAllSynapsesByAxon(axon_id):
             mutil.makeDictIfNot(new_weights[axon_id], dendrite_id)
             
             weight = self.weightAtSynapse(axon_id, dendrite_id)
             error = self.getErrorAt(dendrite_id)
             rate = self.learning_rate
             derivative = self.derivativeOutputAt(dendrite_id)
             output = self.outputAt(axon_id)
             new_weights[axon_id][dendrite_id] = weight + rate * error * derivative * output
             self.setSynapse(axon_id, dendrite_id, new_weights[axon_id][dendrite_id])
示例#4
0
文件: ann.py 项目: Hydex/ann
    def adjustWeights(self):
        new_weights = dict()
        for axon_id in sorted(self.neurons.keys(), reverse=False):
            mutil.makeDictIfNot(new_weights, axon_id)
            for dendrite_id in self.getAllSynapsesByAxon(axon_id):
                mutil.makeDictIfNot(new_weights[axon_id], dendrite_id)

                weight = self.weightAtSynapse(axon_id, dendrite_id)
                error = self.getErrorAt(dendrite_id)
                rate = self.learning_rate
                derivative = self.derivativeOutputAt(dendrite_id)
                output = self.outputAt(axon_id)
                new_weights[axon_id][
                    dendrite_id] = weight + rate * error * derivative * output
                self.setSynapse(axon_id, dendrite_id,
                                new_weights[axon_id][dendrite_id])