Diversity Acquisition Functions#12
Open
jaiswalsuraj487 wants to merge 20 commits intosustainability-lab:mainfrom
Open
Diversity Acquisition Functions#12jaiswalsuraj487 wants to merge 20 commits intosustainability-lab:mainfrom
jaiswalsuraj487 wants to merge 20 commits intosustainability-lab:mainfrom
Conversation
Member
|
@jaiswalsuraj487 Now that our plan is broadened, let's not use |
Author
|
@patel-zeel I have made the required changes as per the current version of |
Author
|
@patel-zeel Added AL notebook for diversity acquisitions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implemented Furthest Acquisition and Centroid Acquisition on commit a6e59ff.
Files Added:
astra/torch/al/acquisitions/furthest.py: contain implementation of Furthest acquisitionastra/torch/al/acquisitions/centroid.py: contain implementation of Centroid acquisitionastra/torch/al/strategies/diversity.py: modified this file as per the needtests/torch/acquisitions/test_furthest.py: contains test for furthest acquisition function.tests/torch/acquisitions/test_centroid.py: contains test for centroid acquisition function.Passes all test cases, including those already existing(commit: a6e59ff).
Explanation:
furthest.py: For the furthest acquisition function, we use the furthest_first method of Classdistil.active_learning_strategies.core_set.CoreSetlink where we pass dummy object strategy as an argument along with labeled_embeddings, unlabeled_embeddings and n. This returns list of indices of n data points that are furthest from all.centroid.py: For the centroid acquisition function: For the Centroid Acquisition function, we pass labeled_embeddings, unlabeled_embeddings , and n as input.Below lines initializes min_dist as tensor with all values infinity of size [len(n_pool)] when our n_train is 0.
Else we find centroid of train data and then pairwise distance between centroid and all pool data.
We find index of n points from pool data, which has max distance.
diversity.py: Since the acquisition function implemented in link takes (unlabeled_embeddings, labeled_embeddings, n) as parameters, I did same and modifieddiversity.pyinstead of using(features, pool_indices, context_indices)suggested indiversity.pyofsustainability-lab/ASTRAtest_furthest.pyandtest_centroid: Used CIFAR10 to test. Here we want to pass features extractor of model instead of forward pass of model, so I implemented feature extractor as below:This feature_extractor gives us features ie. embedding of input.
We then pass this feature_extractor in
strategy.query()which givesbest_indicesbased on furthest or centroid acquisition provided.