X Tutup
The Wayback Machine - https://web.archive.org/web/20210117115503/https://github.com/modAL-python/modAL/issues/38
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

Ranked batch mode sampling - pre-compute pairwise distance to reduce running time #38

Open
nishkaks opened this issue Mar 19, 2019 · 2 comments

Comments

@nishkaks
Copy link

@nishkaks nishkaks commented Mar 19, 2019

The following code is called for computing the pairwise distances for every sample within the batch. This slows down the program significantly for larger batch sizes.

modAL/modAL/batch.py

Lines 93 to 96 in 4029dfd

if n_jobs == 1 or n_jobs is None:
_, distance_scores = pairwise_distances_argmin_min(X_pool[mask], X_training, metric=metric)
else:
distance_scores = pairwise_distances(X_pool[mask], X_training, metric=metric, n_jobs=n_jobs).min(axis=1)

We can compute the pairwise distances once per batch within ranked_batch(outside the for loop) and pass only the minimum distance array to select_instance and assign it directly to

distance_scores = pairwise_distances(X_pool[mask], X_training, metric=metric, n_jobs=n_jobs).min(axis=1)

There is a significant reduction in running time with this change.

@cosmic-cortex - can I contribute this code change to this repo?

@cosmic-cortex
Copy link
Member

@cosmic-cortex cosmic-cortex commented Mar 19, 2019

Yes, your contribution is very much welcome! This document contains a few brief contribution guidelines. Let me know if you have any questions, I am happy to help!

@nishkaks
Copy link
Author

@nishkaks nishkaks commented Mar 20, 2019

Thanks. Will submit a PR over the weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.
X Tutup