We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents fb467a1 + 74ac736 commit b351770Copy full SHA for b351770
tensorpack/test/testcase.py
@@ -0,0 +1,23 @@
1
+import tensorly as tl
2
+import numpy as np
3
+from tensorly.random import random_cp
4
+from tensorpack.cmtf import perform_CP, calcR2X
5
+
6
7
+def testcase(shape: tuple, rankOrig: int, rankNew: int):
8
9
+ '''
10
+ Creates a random CP tensor and converts it into a full tensor.
11
+ Then, it tests the CP-decomposition method to see if the R2X results correctly.
12
13
14
+ tFacOrig = random_cp(shape, rankOrig, full=False)
15
+ tOrig = tl.cp_to_tensor(tFacOrig)
16
17
+ originalR2X = calcR2X(tFacOrig, tOrig)
18
+ assert originalR2X == 1
19
20
+ tFacNew = perform_CP(tOrig, r=rankNew)
21
+ newR2X = calcR2X(tFacNew, tOrig)
22
23
+ return newR2X
0 commit comments