INNER CODE UNIT · Python
NMF3
ShixiangWang/sigminer · inst/py/nmf.py:61
def NMF3(i, V, rank):
print("Starting NMF run: %d." %i)
return {str(i): NMF(V, rank)}
def MultiVNMF(V_tuple, rank, nrun, cores):
'''Run NMF for a target matrix multiple times'''
available_cores = multiprocess.cpu_count()
if available_cores < cores:
print("Only %d cores available but %d cores requested, reset it to available number." %(available_cores, cores))
cores = available_cores
xs = range(1, len(V_tuple) * nrun + 1)
v = list()
with multiprocess.Pool(processes=cores) as p:
v.append(
p.starmap(
NMF3,
zip(
xs,