Skip to content

This is the code for the paper Jacobian-based Causal Discovery with Nonlinear ICA, demonstrating how identifiable representations (particularly, with Nonlinear ICA) can be used to extract the causal graph from an underlying structural equation model (SEM).

License

Notifications You must be signed in to change notification settings

rpatrik96/nl-causal-representations

Repository files navigation

DOI

CI testing pre-commit

Jacobian-based Causal Discovery with Nonlinear ICA

Description

This is the code for the paper Jacobian-based Causal Discovery with Nonlinear ICA, demonstrating how identifiable representations (particularly, with Nonlinear ICA) can be used to extract the causal graph from an underlying structural equation model (SEM).

Before running the code

Singularity container build

singularity build --fakeroot nv.sif nv.def

Logging

  1. First, you need to log into wandb
wandb login #you will find your API key at https://wandb.ai/authorize
  1. Second, you need to specify the project for logging, which you can in the before_fit method in cli.py
    def before_fit(self):
        if isinstance(self.trainer.logger, WandbLogger) is True:
            # required as the parser cannot parse the "-" symbol
            self.trainer.logger.__dict__["_wandb_init"][
                "entity"
            ] = "causal-representation-learning" # <--- modify this line
  1. Then, you can create and run the sweep
wandb sweep sweeps/sweep_file.yaml  # returns sweep ID
wandb agent <ID-comes-here> --count=<number of runs> # when used on a cluster, set it to one and start multiple processes

Usage

  1. Clone
 git clone https://github.com/rpatrik96/nl-causal-representations.git
  1. Install
# install package
pip3 install -e .

# install requirements 
pip install -r requirements.txt

# install pre-commit hooks
pre-commit install
  1. Run:
python3 care_nl_ica/cli.py fit --config configs/config.yaml

Code credits

Our repo extensively relies on cl-ica repo, so please consider citing the corresponding paper as well

Reference

If you find our work useful, please consider citing our TMLR paper

@article{reizinger2023jacobianbased,
  author = {
    Reizinger, Patrik and
    Sharma, Yash and
    Bethge, Matthias and
    Schölkopf, Bernhard and
    Huszár, Ferenc and
    Brendel, Wieland
  },
  title = {
    Jacobian-based Causal Discovery with Nonlinear {ICA}
  },
  journal={Transactions on Machine Learning Research},
  issn={2835-8856},
  year={2023},
  url={https://openreview.net/forum?id=2Yo9xqR6Ab},
}

About

This is the code for the paper Jacobian-based Causal Discovery with Nonlinear ICA, demonstrating how identifiable representations (particularly, with Nonlinear ICA) can be used to extract the causal graph from an underlying structural equation model (SEM).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published