From c4667d6f28641d256b6dd4db9b65b71b9a943fb8 Mon Sep 17 00:00:00 2001 From: Fize Jacques Date: Mon, 4 Mar 2019 18:21:57 +0100 Subject: [PATCH] add Parralelization graph embedding --- gmatch4py/embedding/deepwalk.pyx | 2 +- gmatch4py/embedding/graph2vec.pyx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gmatch4py/embedding/deepwalk.pyx b/gmatch4py/embedding/deepwalk.pyx index 2023259..104ab04 100644 --- a/gmatch4py/embedding/deepwalk.pyx +++ b/gmatch4py/embedding/deepwalk.pyx @@ -116,7 +116,7 @@ cdef class DeepWalk(Base): def extract_embedding(self, listgs): from tqdm import tqdm - models = [process(nx.Graph(g)) for g in tqdm(listgs,desc="Extracting Embeddings...")] + models = Parallel(n_jobs = cpu_count())(delayed(process)(nx.Graph(g)) for g in tqdm(listgs,desc="Extracting Embeddings...")) return models @cython.boundscheck(False) diff --git a/gmatch4py/embedding/graph2vec.pyx b/gmatch4py/embedding/graph2vec.pyx index 727baa3..6696662 100644 --- a/gmatch4py/embedding/graph2vec.pyx +++ b/gmatch4py/embedding/graph2vec.pyx @@ -89,7 +89,7 @@ def generate_model(graphs, iteration = 2, dimensions = 64, min_count = 5, down_s Main function to read the graph list, extract features, learn the embedding and save it. :param args: Object with the arguments. """ - document_collections = [feature_extractor(g, ix,iteration) for ix,g in tqdm(enumerate(graphs),desc="Extracting Features...")] + document_collections = Parallel(n_jobs = workers)(delayed(feature_extractor)(g, ix,iteration) for ix,g in tqdm(enumerate(graphs),desc="Extracting Features...")) graphs=[nx.relabel_nodes(g,{node:str(node) for node in list(g.nodes)},copy=True) for g in graphs] model = Doc2Vec(document_collections, vector_size = dimensions, -- GitLab