def update_dist(self, indexcomp, comp, norm, last_comp=False, classifier=None):
"""
Calculate the distance from the supplied pattern to the stored pattern
"""
# Called from CM1KEmulator.update_all_neuron_dists(), i.e., whenever COMP or LCOMP is updated
log.trace("Neuron.update_dist()")
if norm == cm1k.CM1KDistNorm.l1:
self.dist += abs(comp - self.pattern[indexcomp])
elif norm == cm1k.CM1KDistNorm.lsup:
self.dist = max(abs(comp - self.pattern[indexcomp]), self.dist)
elif norm == cm1k.CM1KDistNorm.euc:
self.dist += (comp - self.pattern[indexcomp]) * (comp - self.pattern[indexcomp])
if last_comp:
if norm == cm1k.CM1KDistNorm.euc:
self.dist = int(round(math.sqrt(self.dist)))
if (classifier == cm1k.CM1KClassifier.rbf and self.dist < self.aif) or classifier == cm1k.CM1KClassifier.knn:
# The neuron has fired
self.chip.store_firing_neuron(self)
评论列表
文章目录