From 77a732e5ec4276f74ea1d4a3a082c331a1b34aff Mon Sep 17 00:00:00 2001 From: Komal Kumar Date: Fri, 8 Jan 2021 16:32:19 -0500 Subject: [PATCH 1/2] Fix for issue #54 --- node2vec/node2vec.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/node2vec/node2vec.py b/node2vec/node2vec.py index ee3056e..fb7d760 100644 --- a/node2vec/node2vec.py +++ b/node2vec/node2vec.py @@ -139,7 +139,7 @@ def _generate_walks(self) -> list: :return: List of walks. Each walk is a list of nodes. """ - flatten = lambda l: [item for sublist in l for item in sublist] + def flatten(l): return [item for sublist in l for item in sublist] # Split num_walks for each worker num_walks_lists = np.array_split(range(self.num_walks), self.workers) @@ -177,4 +177,7 @@ def fit(self, **skip_gram_params) -> gensim.models.Word2Vec: if 'size' not in skip_gram_params: skip_gram_params['size'] = self.dimensions + if 'sg' not in skip_gram_params: + skip_gram_params['sg'] = 1 + return gensim.models.Word2Vec(self.walks, **skip_gram_params) From 628ddb30be4318b12bb799eaa1bc88cbd6897d86 Mon Sep 17 00:00:00 2001 From: Komal Kumar Date: Fri, 8 Jan 2021 16:37:38 -0500 Subject: [PATCH 2/2] Reverted unnwanted change --- node2vec/node2vec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node2vec/node2vec.py b/node2vec/node2vec.py index fb7d760..1ef1693 100644 --- a/node2vec/node2vec.py +++ b/node2vec/node2vec.py @@ -139,7 +139,7 @@ def _generate_walks(self) -> list: :return: List of walks. Each walk is a list of nodes. """ - def flatten(l): return [item for sublist in l for item in sublist] + flatten = lambda l: [item for sublist in l for item in sublist] # Split num_walks for each worker num_walks_lists = np.array_split(range(self.num_walks), self.workers)