HodgeExperiments.py 文件源码

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

项目:SlidingWindowVideoTDA 作者: ctralie 项目源码 文件源码
def doRandomFlipExperiment(N, PercentFlips):
    I, J = np.meshgrid(np.arange(N), np.arange(N))
    I = I[np.triu_indices(N, 1)]
    J = J[np.triu_indices(N, 1)]
    NEdges = len(I)
    R = np.zeros((NEdges, 2))
    R[:, 0] = J
    R[:, 1] = I

#    toKeep = int(NEdges/200)
#    R = R[np.random.permutation(NEdges)[0:toKeep], :]
#    NEdges = toKeep

    W = np.random.rand(NEdges)
    #W = np.ones(NEdges)

    Y = np.ones(NEdges)
    NFlips = int(PercentFlips*len(Y))
    Y[np.random.permutation(NEdges)[0:NFlips]] = -1

    (s, I, H) = doHodge(R, W, Y)
    [INorm, HNorm] = [getWNorm(I, W), getWNorm(H, W)]
    return (INorm, HNorm)

#Do a bunch of random flip experiments, varying the percentage
#of flips, and take the mean consistency norms for each percentage
#over a number of trials
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号