wgccaTest.py 文件源码

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

项目:wgcca 作者: abenton 项目源码 文件源码
def test_recoverG(self):
    '''
    Test GCCA implementation by seeing if it can recover G.
    '''

    eps = 1.e-10

    Vs = [self.V1, self.V2, self.V3]

    wgcca = WGCCA.WeightedGCCA(3, [self.F1, self.F2, self.F3],
                               self.k, [eps, eps, eps], verbose=True)
    wgcca.learn(Vs)
    U1 = wgcca.U[0]
    U2 = wgcca.U[1]
    U3 = wgcca.U[2]

    Gprime   = wgcca.G

    # Rotate G to minimize norm of difference between G and G'
    R, B = scipy.linalg.orthogonal_procrustes(self.G, Gprime)
    normDiff = scipy.linalg.norm(self.G.dot(R) - Gprime)

    print ('Recovered G up to rotation; difference in norm:', normDiff)

    self.assertTrue( normDiff < 1.e-6 )
    self.assertTrue( np.allclose(self.G.dot(R), Gprime) )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号