Skip to main content

Concept-Based Deep Learning Library for PyTorch.

Project description

PyC Logo

PyPI Total downloads Codecov Documentation Status

🚀 Getting Started - 📚 Documentation - 💻 User guide

PyC is a library built upon PyTorch and Pytorch Lightning to easily implement interpretable and causally transparent deep learning models. The library provides primitives for layers (encoders, predictors, special layers), probabilistic models, and APIs for running experiments at scale.

The name of the library stands for both

  • PyTorch Concepts: as concepts are essential building blocks for interpretable deep learning.
  • $P(y|C)$: as the main purpose of the library is to support sound probabilistic modeling of the conditional distribution of targets $y$ given concepts $C$.

Quick Start

You can install PyC with core dependencies from PyPI:

pip install pytorch-concepts

After installation, you can import it in your Python scripts as:

import torch_concepts as pyc

Follow our user guide to get started with building interpretable models using PyC!


PyC Software Stack

The library is organized to be modular and accessible at different levels of abstraction:

  • Conceptarium (No-code API). Use case: applications and benchmarking. These APIs allow to easily run large-scale highly parallelized and standardized experiments by interfacing with configuration files. Built on top of Hydra and WandB.
  • High-level APIs. Use case: use out-of-the-box state-of-the-art models. These APIs allow to instantiate use implemented models with 1 line of code. This interface is built in Pytorch Lightning to easily standardize training and evaluation.
  • Mid-level APIs. Use case: build custom interpretable and causally transparent probabilistic graphical models. These APIs allow to build new interpretable probabilistic models and run efficient tensorial probabilistic inference.
  • Low-level APIs. Use case: assemble custom interpretable architectures. These APIs allow to build architectures from basic interpretable layers in a plain PyTorch-like interface. These APIs also include metrics, losses, and datasets.

PyC Software Stack


Contributing

Contributions are welcome! Please check our contributing guidelines to get started.

Thanks to all contributors! 🧡

External Contributors


Cite this Library

If you found this library useful for your research article, blog post, or product, we would be grateful if you would cite it using the following bibtex entry:

@software{pycteam2025concept,
    author = {Barbiero, Pietro and De Felice, Giovanni and Espinosa Zarlenga, Mateo and Ciravegna, Gabriele and Dominici, Gabriele and De Santis, Francesco and Casanova, Arianna and Debot, David and Giannini, Francesco and Diligenti, Michelangelo and Marra, Giuseppe},
    license = {Apache 2.0},
    month = {3},
    title = {{PyTorch Concepts}},
    url = {https://github.com/pyc-team/pytorch_concepts},
    year = {2025}
}

Reference authors: Pietro Barbiero, Giovanni De Felice, and Mateo Espinosa Zarlenga.


Funding

This project is supported by the following organizations:

FWO - Research Foundation Flanders      Hasler Foundation      SNSF - Swiss National Science Foundation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytorch_concepts-1.0.0a1.tar.gz (2.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytorch_concepts-1.0.0a1-py3-none-any.whl (796.4 kB view details)

Uploaded Python 3

File details

Details for the file pytorch_concepts-1.0.0a1.tar.gz.

File metadata

  • Download URL: pytorch_concepts-1.0.0a1.tar.gz
  • Upload date:
  • Size: 2.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for pytorch_concepts-1.0.0a1.tar.gz
Algorithm Hash digest
SHA256 c4d7d7325e6e93f18e5d7e30cdabbb996f55a0de4a7220288d3867acdc13703c
MD5 7dc616c80873003f941086c9cfdbabda
BLAKE2b-256 47f07ba5a3c4533ec8a542b570917fd8e6253b51e4fcfd6b928f104588a54fc4

See more details on using hashes here.

File details

Details for the file pytorch_concepts-1.0.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytorch_concepts-1.0.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 7e15e7443c427cbc8ee2d1b43ad6fcb4a8e5cd57d6348300877dd394feb81786
MD5 8c23d077ed7fddfefe8a2bb031b38e70
BLAKE2b-256 d270a5236af14781621d2e12eaeb2f1c07a2fe2cdbc1b353221fc34333386871

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page