Catalyst
Accelerated deep learning R&D
Install / Use
/learn @catalyst-team/CatalystQuality Score
Category
OperationsSupported Platforms
Tags
README
Accelerated Deep Learning R&D
Catalyst is a PyTorch framework for Deep Learning Research and Development. It focuses on reproducibility, rapid experimentation, and codebase reuse so you can create something new rather than write yet another train loop. <br/> Break the cycle – use the Catalyst!
<details> <summary>Catalyst at PyTorch Ecosystem Day 2021</summary> <p> </p> </details> <details> <summary>Catalyst at PyTorch Developer Day 2021</summary> <p> </p> </details>Getting started
pip install -U catalyst
import os
from torch import nn, optim
from torch.utils.data import DataLoader
from catalyst import dl, utils
from catalyst.contrib.datasets import MNIST
model = nn.Sequential(nn.Flatten(), nn.Linear(28 * 28, 10))
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=0.02)
loaders = {
"train": DataLoader(MNIST(os.getcwd(), train=True), batch_size=32),
"valid": DataLoader(MNIST(os.getcwd(), train=False), batch_size=32),
}
runner = dl.SupervisedRunner(
input_key="features", output_key="logits", target_key="targets", loss_key="loss"
)
# model training
runner.train(
model=model,
criterion=criterion,
optimizer=optimizer,
loaders=loaders,
num_epochs=1,
callbacks=[
dl.AccuracyCallback(input_key="logits", target_key="targets", topk=(1, 3, 5)),
dl.PrecisionRecallF1SupportCallback(input_key="logits", target_key="targets"),
],
logdir="./logs",
valid_loader="valid",
valid_metric="loss",
minimize_valid_metric=True,
verbose=True,
)
# model evaluation
metrics = runner.evaluate_loader(
loader=loaders["valid"],
callbacks=[dl.AccuracyCallback(input_key="logits", target_key="targets", topk=(1, 3, 5))],
)
# model inference
for prediction in runner.predict_loader(loader=loaders["valid"]):
assert prediction["logits"].detach().cpu().numpy().shape[-1] == 10
# model post-processing
model = runner.model.cpu()
batch = next(iter(loaders["valid"]))[0]
utils.trace_model(model=model, batch=batch)
utils.quantize_model(model=model)
utils.prune_model(model=model, pruning_fn="l1_unstructured", amount=0.8)
utils.onnx_export(model=model, batch=batch, file="./logs/mnist.onnx", verbose=True)
Step-by-step Guide
- Start with Catalyst — A PyTorch Framework for Accelerated Deep Learning R&D introduction.
- Try notebook tutorials or check minimal examples for first deep dive.
- Read blog posts with use-cases and guides.
- Learn machine learning with our "Deep Learning with Catalyst" course.
- And finally, join our slack if you want to chat with the team and contributors.
Table of Contents
Overview
Catalyst helps you implement compact but full-featured Deep Learning pipelines with just a few lines of code. You get a training loop with metrics, early-stopping, model checkpointing, and other features without the boilerplate.
Installation
Generic installation:
pip install -U catalyst
<details>
<summary>Specialized versions, extra requirements might apply</summary>
<p>
pip install catalyst[ml] # installs ML-based Catalyst
pip install catalyst[cv] # installs CV-based Catalyst
# master version installation
pip install git+https://github.com/catalyst-team/catalyst@master --upgrade
# all available extensions are listed here:
# https://github.com/catalyst-team/catalyst/blob/master/setup.py
</p>
</details>
Catalyst is compatible with: Python 3.7+. PyTorch 1.4+. <br/> Tested on Ubuntu 16.04/18.04/20.04, macOS 10.15, Windows 10, and Windows Subsystem for Linux.
Documentation
- <details> <summary>2021 edition</summary> <p> </p> </details>
- <details> <summary>2020 edition</summary> <p>



