Repository navigation
Implementation of BALD and BatchBALD query strategy. - #284
Conversation
+ json and tests
|
|
||
| if hasattr(ensemble, "estimators_"): | ||
| if hasattr(ensemble, "estimators_") and \ | ||
| not len(ensemble.estimators_) == 0: |
There was a problem hiding this comment.
| not len(ensemble.estimators_) == 0: | |
| len(ensemble.estimators_) > 0: |
| from ..utils import rand_argmax, MISSING_LABEL, check_type | ||
|
|
||
|
|
||
| class BALD(QueryByCommittee): |
There was a problem hiding this comment.
| class BALD(QueryByCommittee): | |
| class BatchBALD(QueryByCommittee): |
There was a problem hiding this comment.
class
| class BALD(QueryByCommittee): | |
| class BayesianALDisagreement(QueryByCommittee): |
|
|
||
|
|
||
| class BALD(QueryByCommittee): | ||
| """Bayesian Active Learning by Disagreement |
There was a problem hiding this comment.
Batch Bayesian Active Learning by Disagreement (BatchBALD)
|
|
||
| References | ||
| ---------- | ||
| [1] HOULSBY, Neil, et al. Bayesian active learning for classification and |
There was a problem hiding this comment.
Lower cases for the names Houlsby and Kirsch and Van Amersfoort
| return uncertainty - confident | ||
|
|
||
|
|
||
| def _batchbald(probas, batch_size=1): |
There was a problem hiding this comment.
| def _batchbald(probas, batch_size=1): | |
| def batch_bald(probas, batch_size=1): |
Add check for probas and batch_size
| return best_indices | ||
|
|
||
|
|
||
| def _bald(probas): |
There was a problem hiding this comment.
Move to test file to check batch_bald
Codecov ReportPatch coverage:
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## master #284 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 51 52 +1
Lines 4115 4268 +153
==========================================
+ Hits 4115 4268 +153
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
| { | ||
| "class" : "BatchBALD", | ||
| "package" : "pool", | ||
| "method" : "Bayesian Active Learning by Disagreement", |
There was a problem hiding this comment.
| "method" : "Bayesian Active Learning by Disagreement", | |
| "method" : "Bayesian Active Learning by Disagreement (BALD)", |
| { | ||
| "class" : "FourDs", | ||
| "package" : "pool", | ||
| "method" : "Batch Density-Diversity-Distribution-Distance Sampling (4DS)", |
There was a problem hiding this comment.
| "method" : "Batch Density-Diversity-Distribution-Distance Sampling (4DS)", | |
| "method" : "Batch Density-Diversity-Distribution-Distance Sampling (Batch4DS)", |
| @article{kirsch2019batchbald, | ||
| title={Batchbald: Efficient and diverse batch acquisition for deep bayesian active learning}, | ||
| author={Kirsch, Andreas and Van Amersfoort, Joost and Gal, Yarin}, | ||
| journal={Advances in neural information processing systems}, |
There was a problem hiding this comment.
| journal={Advances in neural information processing systems}, | |
| journal={Advances in Neural Information Processing Systems}, |
| def empty(K): | ||
| return _ExactJointEntropy(np.ones((1, K))) | ||
|
|
||
| # def compute(self): |
| The Bayesian-Active-Learning-by-Disagreement (BatchBALD) [1] strategy reduces the | ||
| number of possible hypotheses maximally fast to minimize the uncertainty | ||
| about the parameters using Shannon’s entropy. It seeks the data point that | ||
| maximises the decrease in expected posterior entropy. For the batch case |
There was a problem hiding this comment.
| maximises the decrease in expected posterior entropy. For the batch case | |
| maximises the decrease in expected posterior entropy. For the batch case, |
| n_MC_samples, batch_size - 1, K, C, random_state | ||
| ) | ||
|
|
||
| # We always keep these on the CPU. |
| # Fit the ensemble. | ||
| if fit_ensemble: | ||
| ensemble = clone(ensemble).fit(X, y, sample_weight) | ||
| ensemble = copy.deepcopy(ensemble).fit(X, y, sample_weight) |
|
|
||
| if hasattr(ensemble, "estimators_"): | ||
| if hasattr(ensemble, "estimators_") and \ | ||
| len(ensemble.estimators_) > 0: |
| from skactiveml.utils import MISSING_LABEL, check_random_state | ||
|
|
||
|
|
||
| class TestBALD(TemplateSingleAnnotatorPoolQueryStrategy, unittest.TestCase): |
| @@ -0,0 +1,295 @@ | |||
| import unittest | |||
There was a problem hiding this comment.
rename file: test_batch_bald.py
| { | ||
| "class" : "BatchBALD", | ||
| "package" : "pool", | ||
| "method" : "Bayesian Active Learning by Disagreement (BALD", |
There was a problem hiding this comment.
| "method" : "Bayesian Active Learning by Disagreement (BALD", | |
| "method" : "Bayesian Active Learning by Disagreement (BALD)", |
No description provided.