This repository provides the source code of the experiments for the paper: Deep Out-of-Distribution Uncertainty Quantification via Weight Entropy Maximization (JMLR)
Our method is now available as a Python package on PyPI! 🚀 Easily install it with:
pip install maxwent
For detailed usage and examples, visit this GitHub repository.
🔹 Compatible with TensorFlow & PyTorch
🔹 Comprehensive tutorials included in the documentation
🔹 Easily adaptable to new data
MaxWEnt is an uncertainty quantification method, particularly suited for Out-Of-Distribution detection. The method is designed as an application of the Maximum Entropy principle to stochastic neural networks. Given a set of observations
Where:
-
$\mathbb{E}_{q_{\phi}}[\mathcal{L}_{\mathcal{S}}(w)]$ is the average empirical risk over$q_{\phi}$ -
$\mathbb{E}_{q_{\phi}}[-\log(q_{\phi}(w))]$ is the entropy of$q_{\phi}$ -
$\lambda$ is a trade-off parameter
MaxWEnt significantly improves the out-of-distribution uncertainty estimation in comparison to the main baselines: DeepEnsemble and the standard Bayesian Neural Network (BNN) with centered gaussian prior. The figure below presents the results obtained on two synthetic datasets:
To run the experiments, first clone the repository with:
git clone https://github.com/antoinedemathelin/maxwent-expe.git
or
git clone [email protected]:antoinedemathelin/maxwent-expe.git
On your labtop, create a conda environment (with python 3.11 preferably). Run, for instance,
conda create -n maxwent python=3.11
conda activate maxwent
Then, install the requirements from the requirements.txt
file:
pip install -r requirements.txt
The experiments can then be conducted using one of the following config files: 1d_reg_all
, 2d_classif_all
, uci_all
, citycam_all
in the configs/
folder. For instance:
python run.py --config configs/1d_reg_all.yml
A single experiment can also be conducted for a particular dataset and method:
python run.py -c configs/uci.yml -d yacht_interpol -m MCDropout -p {'rate':0.1}
The models are stored in the results/
folder and the scores in the logs/
folder.
Note : the CityCam dataset should first be downloaded from this website, then preprocessed with the following command line:
python preprocessing_citycam.py <path_to_the_citycam_dataset_on_your_labtop>
If you use this repository in your research, please cite our work using the following reference:
@article{JMLR:v26:23-1359,
author = {Antoine de Mathelin and Fran{\c{c}}ois Deheeger and Mathilde Mougeot and Nicolas Vayatis},
title = {Deep Out-of-Distribution Uncertainty Quantification via Weight Entropy Maximization},
journal = {Journal of Machine Learning Research},
year = {2025},
volume = {26},
number = {4},
pages = {1--68},
url = {http://jmlr.org/papers/v26/23-1359.html}
}