Code for the paper âImproving Out-of-Distribution Detection with Markov Logic Networksâ as accepted at ICML2025.
pip install -r requirements.txtThe code uses Hydra for configuration.
You will have to download the CUB200 and GTSRB dataset and extract them to a folder called data/.
Each dataset code lives in its own subfolder with a train.py that:
-
Trains neural networks (serving as interpretations of predicates and functions in the constraints).
-
Saves:
- Model checkpoints
- Network predictions on in-distribution (ID) and out-of-distribution (OOD) datasets
- Network feature representations for ID and OOD data
Run test.py to:
- Train a Markov Logic Network (MLN)
- Evaluate OOD detectors using the pre-extracted predictions and features
Use mining.py to automatically mine logical constraints from the data.
compiler.pyCompiles a domain-specific FOL notation into Python code.detectors.pyWraps detectors from thepytorch-oodlibrary for easy use.mln.pyImplements the Markov Logic Network.shared.pyUtilities shared across datasets (e.g., MLN training loops, evaluation helpers).