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) )
评论列表
文章目录