@@ -44,7 +44,7 @@ def criteria(loglik, T, prms, n):
44
44
45
45
46
46
def estep (prms , fd , U ):
47
- Y = fd ['coefs' ].T
47
+ Y = np . asarray ( fd ['coefs' ].T )
48
48
n = Y .shape [0 ]
49
49
p = Y .shape [1 ]
50
50
K = prms ['K' ]
@@ -81,7 +81,7 @@ def estep(prms, fd, U):
81
81
def fstep (fd , T , lambda_ ):
82
82
if np .min (np .sum (T , axis = 0 )) <= 1 :
83
83
raise ValueError ("One cluster is almost empty!" )
84
- G = fd ['coefs' ].T
84
+ G = np . asarray ( fd ['coefs' ].T )
85
85
d = T .shape [1 ] - 1
86
86
basisobj = fd ['basis' ]
87
87
W = inprod (basisobj , basisobj )
@@ -94,15 +94,15 @@ def fstep(fd, T, lambda_):
94
94
x_predict = X [:, i ]
95
95
enet = ElasticNet (alpha = lambda_ , l1_ratio = 0.5 , fit_intercept = False )
96
96
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 ( )
99
99
U = svd (Utilde , full_matrices = False )[0 ]
100
100
return U
101
101
102
102
103
103
def fem_main_func (fd , K , model = 'AkjBk' , init = 'kmeans' , lambda_ = 0 , Tinit = None ,
104
104
maxit = 50 , eps = 1e-8 , graph = False ):
105
- Y = fd ['coefs' ].T
105
+ Y = np . asarray ( fd ['coefs' ].T )
106
106
n = Y .shape [0 ]
107
107
Lobs = np .full (maxit + 1 , - np .inf )
108
108
if init == 'user' :
0 commit comments