Skip to content

Commit f3a5e6f

Browse files
authored
Update fem_main_func.py
1 parent ad01f15 commit f3a5e6f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

BiFuncLib/fem_main_func.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def criteria(loglik, T, prms, n):
4444

4545

4646
def estep(prms, fd, U):
47-
Y = fd['coefs'].T
47+
Y = np.asarray(fd['coefs'].T)
4848
n = Y.shape[0]
4949
p = Y.shape[1]
5050
K = prms['K']
@@ -81,7 +81,7 @@ def estep(prms, fd, U):
8181
def fstep(fd, T, lambda_):
8282
if np.min(np.sum(T, axis=0)) <= 1:
8383
raise ValueError("One cluster is almost empty!")
84-
G = fd['coefs'].T
84+
G = np.asarray(fd['coefs'].T)
8585
d = T.shape[1] - 1
8686
basisobj = fd['basis']
8787
W = inprod(basisobj, basisobj)
@@ -94,15 +94,15 @@ def fstep(fd, T, lambda_):
9494
x_predict = X[:, i]
9595
enet = ElasticNet(alpha=lambda_, l1_ratio=0.5, fit_intercept=False)
9696
enet.fit(x_predict, G)
97-
coef = enet.coef_.ravel()
98-
Utilde[:, i] = coef / np.sqrt(np.sum(np.square(coef)))
97+
coef = enet.coef_
98+
Utilde[:, i] = (coef / np.sqrt(np.sum(np.square(coef)))).ravel()
9999
U = svd(Utilde, full_matrices=False)[0]
100100
return U
101101

102102

103103
def fem_main_func(fd, K, model='AkjBk', init='kmeans', lambda_=0, Tinit=None,
104104
maxit=50, eps=1e-8, graph=False):
105-
Y = fd['coefs'].T
105+
Y = np.asarray(fd['coefs'].T)
106106
n = Y.shape[0]
107107
Lobs = np.full(maxit + 1, -np.inf)
108108
if init == 'user':

0 commit comments

Comments
 (0)