Package: baal
Bayesian Active Learning (Baal)Baal is an active learning library that supports both industrial applications and research usecases.Read the documentation athttps://baal.readthedocs.io.Our paper can be read onarXiv. It includes tips and tricks to make active learning
usable in production.For a quick introduction to Baal and Bayesian active learning, please see these links:Seminar with Label StudioUser guideBayesian active learning presentationBaal was initially developed atElementAI(acquired by ServiceNow in 2021), but is now independant.Installation and requirementsBaal requiresPython>=3.8.To install Baal using pip:pip install baalWe usePoetryas our package manager.
To install Baal from source:poetry installPapers using BaalBayesian active learning for production, a systematic study and a reusable library(Atighehchian et al. 2020)Synbols: Probing Learning Algorithms with Synthetic Datasets(Lacoste et al. 2020)Can Active Learning Preemptively Mitigate Fairness Issues?(Branchaud-Charron et al. 2021)Active learning with MaskAL reduces annotation effort for training Mask R-CNN(
Blok et al. 2021)Stochastic Batch Acquisition for Deep Active Learning(Kirsch et al. 2022)What is active learning?Active learning is a special case of machine learning in which a learning algorithm is able to interactively query the
user (or some other information source) to obtain the desired outputs at new data points
(to understand the concept in more depth, refer to ourtutorial).Baal FrameworkAt the moment Baal supports the following methods to perform active learning.Monte-Carlo Dropout (Gal et al. 2015)MCDropConnect (Mobiny et al. 2019)Deep ensemblesSemi-supervised learningIf you want to propose new methods, please submit an issue.TheMonte-Carlo Dropoutmethod is a known approximation for Bayesian neural networks. In this method, the Dropout
layer is used both in training and test time. By running the model multiple times whilst randomly dropping weights, we
calculate the uncertainty of the prediction using one of the uncertainty measurements
inheuristics.py.The framework consists of four main parts, as demonstrated in the flowchart below:ActiveLearningDatasetHeuristicsModelWrapperActiveLearningLoopTo get started, wrap your dataset in ourActiveLearningDatasetclass. This will ensure
that the dataset is split intotrainingandpoolsets. Thepoolset represents the portion of the training set which is yet to be labelled.We provide a lightweight objectModelWrappersimilar tokeras.Modelto make it easier to
train and test the model. If your model is not ready for active learning, we provide Modules to prepare them.For example, theMCDropoutModulewrapper changes the existing dropout layer to be used
in both training and inference time and theModelWrappermakes the specifies the number of iterations to run at
training and inference.Finally,ActiveLearningLoopautomatically computes the uncertainty and label the most
uncertain items in the pool.In conclusion, your script should be similar to this:dataset=ActiveLearningDataset(your_dataset)dataset.label_randomly(INITIAL_POOL)# label some datamodel=MCDropoutModule(your_model)model=ModelWrapper(model,your_criterion)active_loop=ActiveLearningLoop(dataset,get_probabilities=model.predict_on_dataset,heuristic=heuristics.BALD(),iterations=20,# Number of MC sampling.query_size=QUERY_SIZE)# Number of item to label.foral_stepinrange(N_ALSTEP):model.train_on_dataset(dataset,optimizer,BATCH_SIZE,use_cuda=use_cuda)metrics=model.test_on_dataset(test_dataset,BATCH_SIZE)# Label the next most uncertain items.ifnotactive_loop.step():# We're done!breakFor a complete experiment, seeexperiments/vgg_mcdropout_cifar10.py.Re-run our Experimentsdockerbuild[--targetbase_baal]-tbaal.
dockerrun--rmbaal--gpusallpython3experiments/vgg_mcdropout_cifar10.pyUse Baal for YOUR ExperimentsSimply clone the repo, and create your own experiment script similar to the example
atexperiments/vgg_mcdropout_cifar10.py. Make sure to use the four main parts of Baal
framework.Happy running experimentsContributing!To contribute, seeCONTRIBUTING.md.Who We Are!"There is passion, yet peace; serenity, yet emotion; chaos, yet order."The Baal team tests and implements the most recent papers on uncertainty estimation and active learning.Current maintainers:Parmida AtighehchianFrédéric Branchaud-CharronGeorge PearseHow to citeIf you used Baal in one of your project, we would greatly appreciate if you cite this library using this Bibtex:@misc{atighehchian2019baal,
  title={Baal, a bayesian active learning library},
  author={Atighehchian, Parmida and Branchaud-Charron, Frederic and Freyberg, Jan and Pardinas, Rafael and Schell, Lorne
          and Pearse, George},
  year={2022},
  howpublished={\url{https://github.com/baal-org/baal/}},
}LicenceTo get information on licence of this API please readLICENCE