INNER CODE UNIT · Python
MultiVNMF
ShixiangWang/sigminer · inst/py/nmf.py:65
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,
list(itertools.chain.from_iterable(itertools.repeat(i, nrun) for i in V_tuple)),
repeat(rank)
)))