This repo contains official implementation of Identity Curvature Laplace Approximation for Improved Out-of-Distribution Detection [WACV 2025] by Maksim Zhdanov, Stanislav Dereka and Sergey Kolesnikov. The implementation is based on OpenOOD.
- Build Miniconda environment from
env_laplace.yml
by runningconda env create -f env_laplace.yml
. - Alternatively, you can build Docker image from
Dockerfile
. - Additionally, you need to install
asdfghjkl
backend by runningpip install git+https://[email protected]/wiseodd/asdl@asdfghjkl
. - Download the datasets:
bash /scripts/download/download.sh
Note. If some links in download.sh
are broken,
download the datasets by yourself from the official
repositories and refer to ./scripts/imglist_generator.py
to prepare image lists in OpenOOD format.
As we use wandb as a monitoring tool, you need to set wandb environment variables in .env file:
WANDB_API_KEY=<YOUR_KEY>
Note: ICLA and LLLA variant are all post-hoc methods which do not require any training.
Note: all the experiments on cifar10
, cifar100
, imagenet-200
are guaranteed to run on a single Nvidia A100 GPU.
In evaluation .sh scripts, you can tweak the following parameters:
EXP_NAME='name'
- the name of your experiment in Wandb.export CUDA_VISIBLE_DEVICES=0
- ID of your CUDA device.--postprocessor.postprocessor_args.llla_type 'type'
- type of Laplace Approximation to use. Supported variants areef
,ggn
,k-fac
andicla
.--postprocessor.postprocessor_args.optimize_precision true
- optimize prior precision or not. This corresponds to ICLA and ICLA (zero) algorithms in the paper.--recorder.project icla
- the name of your Wandb project.
Run one of the following commands to reproduce the results from the paper. You can use LLLA with EF, GGN, K-FAC or ICLA (ours).
Empirical Fisher (EF)
bash scripts/ood/icla/cifar10_llla_ef_eval.sh
Generalized Gauss-Newton (GGN).=
bash scripts/ood/icla/cifar10_llla_ggn_eval.sh
Kronecker-Factored Approximate Curvature (K-FAC)
bash scripts/ood/icla/cifar10_llla_kfac_eval.sh
Identity Curvature Laplace Approximation (ICLA)
bash scripts/ood/icla/cifar10_llla_icla_eval.sh
Identity Curvature Laplace Approximation (ICLA) with Precision Zero Hessian Optimization
bash scripts/ood/icla/cifar10_llla_icla_zero_eval.sh
Empirical Fisher (EF)
bash scripts/ood/icla/cifar100_llla_ef_eval.sh
Generalized Gauss-Newton (GGN)
bash scripts/ood/icla/cifar100_llla_ggn_eval.sh
Kronecker-Factored Approximate Curvature (K-FAC)
bash scripts/ood/icla/cifar100_llla_kfac_eval.sh
Identity Curvature Laplace Approximation (ICLA)
bash scripts/ood/icla/cifar100_llla_icla_eval.sh
Identity Curvature Laplace Approximation (ICLA) with Precision Zero Hessian Optimization
bash scripts/ood/icla/cifar100_llla_icla_zero_eval.sh
Empirical Fisher (EF).
bash scripts/ood/icla/im200_llla_ef_eval.sh
Generalized Gauss-Newton (GGN).
bash scripts/ood/icla/im200_llla_ggn_eval.sh
Kronecker-Factored Approximate Curvature (K-FAC).
bash scripts/ood/icla/im200_llla_kfac_eval.sh
Identity Curvature Laplace Approximation (ICLA)
bash scripts/ood/icla/im200_llla_icla_eval.sh
Identity Curvature Laplace Approximation (ICLA) with Precision Zero Hessian Optimization
bash scripts/ood/icla/im200_llla_icla_zero_eval.sh
If you used this code for your research or a project, please cite us as:
@misc{zhdanov2024identitycurvaturelaplaceapproximation,
title={Identity Curvature Laplace Approximation for Improved Out-of-Distribution Detection},
author={Maksim Zhdanov and Stanislav Dereka and Sergey Kolesnikov},
year={2024},
eprint={2312.10464},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2312.10464},
}