Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Poincare model training #2589

Merged
merged 3 commits into from Sep 7, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion gensim/models/poincare.py
Expand Up @@ -567,10 +567,12 @@ def _handle_duplicates(vector_updates, node_indices):

"""
counts = Counter(node_indices)
node_dict = defaultdict(list)
[node_dict[node_index].append(i) for i, node_index in enumerate(node_indices)]
piskvorky marked this conversation as resolved.
Show resolved Hide resolved
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