User Guide¶
Welcome to the PyC User Guide! This guide will help you get started with PyTorch Concepts and build interpretable deep learning models.
Explore Based on Your Background¶
PyC is designed to accommodate users with different backgrounds and expertise levels.
Pick the best entry point based on your experience:
Start from the Low-Level API to build models from basic interpretable layers.
Start from the Mid-Level API to build custom probabilistic models.
Start from the Mid-Level API to build Structural Equation Models for causal inference.
Quick Start Example¶
Here’s a minimal example using the low-Level API:
import torch
import torch_concepts as pyc
# Create a concept bottleneck model
model = torch.nn.ModuleDict({
'encoder': pyc.nn.LinearZC(
in_features=64,
out_features=10
),
'predictor': pyc.nn.LinearCC(
in_features_endogenous=10,
out_features=5
),
})
# Forward pass
x = torch.randn(32, 64)
concepts = model['encoder'](input=x)
predictions = model['predictor'](endogenous=concepts)
For complete examples with training, interventions, and evaluation, see the individual API guides above.
Additional Resources¶
- Examples
Check out complete examples for real-world use cases.
Need Help?¶
Issues: GitHub Issues
Discussions: GitHub Discussions
Contributing: Contributor Guide