Installation

Braincoder requires Python 3.10+ and Keras 3 with at least one backend (TensorFlow, JAX, or PyTorch).

Choosing a backend

Keras 3 supports three backends. Set the KERAS_BACKEND environment variable before importing braincoder:

export KERAS_BACKEND=tensorflow  # default
export KERAS_BACKEND=jax
export KERAS_BACKEND=torch

Or set it permanently in ~/.keras/keras.json:

{"backend": "tensorflow"}

Each backend must be installed separately. The environment.yml includes all three (tensorflow, jax[cpu], torch), but you can install only the one you need.

pip-only install

braincoder is not on PyPI, so install a tagged release from GitHub, together with a backend:

pip install "braincoder @ git+https://github.com/Gilles86/braincoder.git@v0.6.2" tensorflow   # TensorFlow
# or
pip install "braincoder @ git+https://github.com/Gilles86/braincoder.git@v0.6.2" "jax[cpu]"   # JAX
# or
pip install "braincoder @ git+https://github.com/Gilles86/braincoder.git@v0.6.2" torch        # PyTorch

Pin a tag like this in your project’s environment, so that its results stay reproducible.

For a development install from source:

git clone https://github.com/Gilles86/braincoder.git
cd braincoder
pip install -e . tensorflow

Additional dependencies

Some features require optional packages:

  • MCMC sampling: blackjax (JAX backend recommended)

  • Notebooks / tutorials: jupyter, ipykernel

  • Tests: pytest (or pip install -e ".[test]" from a clone)

Verifying the install

python -c "import braincoder; print(braincoder.__version__)"
pytest tests/