neuron.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:CM1K_emulator 作者: kebwi 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号