INNER CODE UNIT · Python
xs
ShixiangWang/sigminer · inst/py/nmf.py:40
xs = range(1, nrun + 1)
with multiprocess.Pool(processes=cores) as p:
v = p.starmap(NMF2, zip(xs, repeat(V), repeat(rank)))
if return_best:
print("Compare KLD and return the best.")
l = len(v)
kld = v[0]["KLD"]
idx = 0
for i in range(1, l):
k = v[i]["KLD"]
print("KLD to compare: %f, KLD to be compared: %f" %(k, kld))
if kld > k:
print("Current KLD value updated to %f" %k)
kld = k
idx = i
print("Return the run #%d" %(idx+1))
v = v[idx]