Skip to content

Commit 0c47de1

Browse files
committed
Adds random_state option to coupled decomposition
1 parent 54d6ce1 commit 0c47de1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tensorpack/coupled.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(self, data: xr.Dataset, rank):
5858
self.unfold = {mode: xr_unfold(data, mode) for mode in self.modes}
5959

6060

61-
def initialize(self, method="svd", verbose=False):
61+
def initialize(self, method="svd", verbose=False, random_state=215):
6262
""" Initialize each mode factor matrix """
6363
# wipe off old values
6464
self.x["_Weight_"][:] = np.ones_like(self.x["_Weight_"])
@@ -86,7 +86,7 @@ def initialize(self, method="svd", verbose=False):
8686
if method == "svd":
8787
self.x["_" + mmode][:, :ncol] = np.linalg.svd(unfold)[0][:,:ncol]
8888
else: # randomized_svd
89-
self.x["_" + mmode][:, :ncol] = randomized_svd(unfold, ncol, random_state=2)[0]
89+
self.x["_" + mmode][:, :ncol] = randomized_svd(unfold, ncol, random_state=random_state)[0]
9090
if verbose:
9191
print(f"{mmode} SVD initialization: done in {time.time() - start_time}")
9292
if method == "nmf":

0 commit comments

Comments
 (0)