Skip to content

Commit

Permalink
Optimize Poincare model training (#2589)
Browse files Browse the repository at this point in the history
* fix list operation

* fix variable name

* fix list comprehension
  • Loading branch information
koiizukag authored and mpenkov committed Sep 7, 2019
1 parent 4c8be8b commit a47eed8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gensim/models/poincare.py
Expand Up @@ -567,10 +567,13 @@ def _handle_duplicates(vector_updates, node_indices):
"""
counts = Counter(node_indices)
node_dict = defaultdict(list)
for i, node_index in enumerate(node_indices):
node_dict[node_index].append(i)
for node_index, count in counts.items():
if count == 1:
continue
positions = [i for i, index in enumerate(node_indices) if index == node_index]
positions = node_dict[node_index]
# Move all updates to the same node to the last such update, zeroing all the others
vector_updates[positions[-1]] = vector_updates[positions].sum(axis=0)
vector_updates[positions[:-1]] = 0
Expand Down

0 comments on commit a47eed8

Please sign in to comment.