Skip to content

Commit 06fc08f

Browse files
author
Potluru, Vamsi
committed
runs in python3
1 parent 9e4613d commit 06fc08f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

sparse_nmf.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def sparse_nmf(X, r, maxiter, spar, W = None, H = None):
3434
Obj = np.zeros(maxiter)
3535
for i in range(maxiter):
3636
Obj[i] = np.linalg.norm(X - np.dot(W, H), 'fro')
37-
print 'iter:', i + 1, 'Obj: ', Obj[i]
37+
print('iter: {} Obj: {}'.format(i + 1, Obj[i]))
3838
W = update_W(X, W, H, spar)
3939
H = update_H(X, W, H)
4040

@@ -132,10 +132,10 @@ def sparse_opt(b, k):
132132
normb = np.cumsum(b * b)
133133
pnormb = np.arange(1, n + 1) * normb
134134
y = (pnormb - sumb * sumb) / (np.arange(1, n + 1) - k * k)
135-
bot = np.ceil(k * k)
135+
bot = np.int(np.ceil(k * k))
136136
z = np.zeros(n)
137137
if bot > n:
138-
print 'Looks like the sparsity measure is not between 0 and 1\n'
138+
print('Looks like the sparsity measure is not between 0 and 1\n')
139139
return
140140
obj = (-np.sqrt(y) * (np.arange(1, n + 1) + k) + sumb) / np.arange(1, n + 1)
141141
indx = np.argmax(obj[bot:n])
@@ -161,5 +161,5 @@ def sparse_opt(b, k):
161161
plt.ion()
162162

163163
plt.show(True)
164-
import ipdb
165-
ipdb.set_trace()
164+
#import ipdb
165+
#ipdb.set_trace()

0 commit comments

Comments
 (0)