audiostream_tp.py 文件源码

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

项目:nupic-example-code 作者: htm-community 项目源码 文件源码
def calcAnomaly(self, actual, predicted):
    """
    Calculates the anomaly of two SDRs

    Uses the equation presented on the wiki: 
    https://github.com/numenta/nupic/wiki/Anomaly-Score-Memo

    To put this in terms of the temporal pooler:
      A is the actual input array at a given timestep
      P is the predicted array that was produced from the previous timestep(s)
      [A - (A && P)] / [A]
    Rephrasing as questions:
      What bits are on in A that are not on in P?
      How does that compare to total on bits in A?

    Outputs 0 is there's no difference between P and A.
    Outputs 1 if P and A are totally distinct.

    Not a perfect metric - it doesn't credit proximity
    Next step: combine with a metric for a spatial pooler
    """
    combined = numpy.logical_and(actual, predicted)
    delta = numpy.logical_xor(actual,combined)
    delta_score = sum(delta)
    actual_score = float(sum(actual))
    return delta_score / actual_score
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号