main_test.py 文件源码

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

项目:ObjRecPoseEst 作者: paroj 项目源码 文件源码
def getAccRel(sim,dst):
    # for how many is the most similar one also the one with the smallest dst
    #  relaxed formulation: of the most similar ones (if more than one is equally similar) one is among those with smallest dst (if more than one is equally far away)
    maxSim = numpy.max(sim, axis=1)
    minDst = numpy.min(dst, axis=1)
    nSamp = sim.shape[0]
    nCorrect = 0.
    nCorrectClass = 0.
    for i in xrange(nSamp):
        maxSimIdx, = (sim[i,:] == maxSim[i]).nonzero()
        minDstIdx, = (dst[i,:] == minDst[i]).nonzero()
        if len(numpy.intersect1d(maxSimIdx,minDstIdx, assume_unique=True)) > 0:
            nCorrect += 1.

        if numpy.min(sim[i,minDstIdx]) > -2.:
            nCorrectClass += 1.

    acc = nCorrect / nSamp

    # classification accuracy. for how many percent is the closest from the correct class
    classAcc = nCorrectClass / nSamp

    return (acc,classAcc)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号