Poutyne

A simplified framework and utilities for PyTorch
Alternatives To Poutyne
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Transformers112,535641,86913 hours ago114July 18, 2023844apache-2.0Python
🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
Pytorch71,1753,3416,72813 hours ago37May 08, 202312,795otherPython
Tensors and Dynamic neural networks in Python with strong GPU acceleration
Keras59,44557817 hours ago80June 27, 202398apache-2.0Python
Deep Learning for humans
Yolov541,907
a day ago8September 21, 2021222agpl-3.0Python
YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
Annotated_deep_learning_paper_implementations36,22318 days ago78September 24, 202227mitJupyter Notebook
🧑‍🏫 60 Implementations/tutorials of deep learning papers with side-by-side notes 📝; including transformers (original, xl, switch, feedback, vit, ...), optimizers (adam, adabelief, sophia, ...), gans(cyclegan, stylegan2, ...), 🎮 reinforcement learning (ppo, dqn), capsnet, distillation, ... 🧠
Made With Ml34,217
a day ago5May 15, 20194mitJupyter Notebook
Learn how to design, develop, deploy and iterate on production-grade ML applications.
Deepspeed28,6115315 hours ago68July 17, 2023799apache-2.0Python
DeepSpeed is a deep learning optimization library that makes distributed training and inference easy, efficient, and effective.
Ray27,9228029813 hours ago87July 24, 20233,428apache-2.0Python
Ray is a unified framework for scaling AI and Python applications. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.
Lightning24,728762013 hours ago253July 25, 2023686apache-2.0Python
Deep learning framework to train, deploy, and ship AI products Lightning fast.
Fastai24,5521841452 days ago146March 28, 2023186apache-2.0Jupyter Notebook
The fastai deep learning library
Alternatives To Poutyne
Select To Compare


Alternative Project Comparisons
Readme

Poutyne Logo

poutyne version - PyPI PyPI status License: LGPL v3 Python version - PyPI CI/CD codecov Downloads

Here is Poutyne.

Poutyne is a simplified framework for PyTorch and handles much of the boilerplating code needed to train neural networks.

Use Poutyne to:

  • Train models easily.
  • Use callbacks to save your best model, perform early stopping and much more.

Read the documentation at Poutyne.org.

Poutyne is compatible with the latest version of PyTorch and Python >= 3.8.

Cite

@misc{Paradis_Poutyne_A_Simplified_2020,
    author = {Paradis, Frdrik and Beauchemin, David and Godbout, Mathieu and Alain, Mathieu and Garneau, Nicolas and Otte, Stefan and Tremblay, Alexis and Blanger, Marc-Antoine and Laviolette, Franois},
    title  = {{Poutyne: A Simplified Framework for Deep Learning}},
    year   = {2020},
    url    = {https://poutyne.org}
}

Getting started: few seconds to Poutyne

The core data structure of Poutyne is a Model, a way to train your own PyTorch neural networks.

How Poutyne works is that you create your PyTorch module (neural network) as usual but when comes the time to train it you feed it into the Poutyne Model, which handles all the steps, stats and callbacks, similar to what Keras does.

Here is a simple example:

# Import the Poutyne Model and define a toy dataset
from poutyne import Model
import torch
import torch.nn as nn
import numpy as np
import torchmetrics

num_features = 20
num_classes = 5
hidden_state_size = 100

num_train_samples = 800
train_x = np.random.randn(num_train_samples, num_features).astype('float32')
train_y = np.random.randint(num_classes, size=num_train_samples).astype('int64')

num_valid_samples = 200
valid_x = np.random.randn(num_valid_samples, num_features).astype('float32')
valid_y = np.random.randint(num_classes, size=num_valid_samples).astype('int64')

num_test_samples = 200
test_x = np.random.randn(num_test_samples, num_features).astype('float32')
test_y = np.random.randint(num_classes, size=num_test_samples).astype('int64')

Select a PyTorch device so that it runs on GPU if you have one:

cuda_device = 0
device = torch.device("cuda:%d" % cuda_device if torch.cuda.is_available() else "cpu")

Create yourself a PyTorch network:

network = nn.Sequential(
    nn.Linear(num_features, hidden_state_size),
    nn.ReLU(),
    nn.Linear(hidden_state_size, num_classes)
)

You can now use Poutyne's model to train your network easily:

model = Model(
    network,
    'sgd',
    'cross_entropy',
    batch_metrics=['accuracy'],
    epoch_metrics=['f1', torchmetrics.AUROC(num_classes=num_classes, task="multiclass")],
    device=device
)
model.fit(
    train_x, train_y,
    validation_data=(valid_x, valid_y),
    epochs=5,
    batch_size=32
)

Since Poutyne is inspired by Keras, one might have notice that this is really similar to some of its functions.

You can evaluate the performances of your network using the evaluate method of Poutyne's model:

loss, (accuracy, f1score) = model.evaluate(test_x, test_y)

Or only predict on new data:

predictions = model.predict(test_x)

See the complete code here. Also, see this for an example for regression.

One of the strengths Poutyne are callbacks. They allow you to save checkpoints, log training statistics and more. See this notebook for an introduction to callbacks. In that vein, Poutyne also offers an ModelBundle class that offers automatic checkpointing, logging and more using callbacks under the hood. Here is an example of usage.

from poutyne import ModelBundle

# Everything is saved in ./saves/my_classification_network
model_bundle = ModelBundle.from_network(
    './saves/my_classification_network', network, optimizer='sgd', task='classif', device=device
)

model_bundle.train_data(train_x, train_y, validation_data=(valid_x, valid_y), epochs=5)

model_bundle.test_data(test_x, test_y)

See the complete code here. Also, see this for an example for regression.


Installation

Before installing Poutyne, you must have the latest version of PyTorch in your environment.

  • Install the stable version of Poutyne:
pip install poutyne
  • Install the latest development version of Poutyne:
pip install -U git+https://github.com/GRAAL-Research/poutyne.git@dev
  • Install and develop on top of the provided Docker Image
docker pull ghcr.io/graal-research/poutyne:latest

Learning Material

Blog posts

  • Medium PyTorch post - Presentation of the basics of Poutyne and how it can help you be more efficient when developing neural networks with PyTorch.

Examples

Look at notebook files with full working examples:

or in Google Colab:

Videos


Contributing to Poutyne

We welcome user input, whether it is regarding bugs found in the library or feature propositions ! Make sure to have a look at our contributing guidelines for more details on this matter.


Sponsors

This project supported by Frdrik Paradis and David Beauchemin. Join the sponsors - show your and support, and appear on the list!


License

Poutyne is LGPLv3 licensed, as found in the LICENSE file.


Why this name, Poutyne?

Poutyne's name comes from poutine, the well-known dish from Quebec. It is usually composed of French fries, squeaky cheese curds and brown gravy. However, in Quebec, poutine also has the meaning of something that is an "ordinary or common subject or activity". Thus, Poutyne will get rid of the ordinary boilerplate code that plain PyTorch training usually entails.

Poutine Yuri Long from Arlington, VA, USA [CC BY 2.0]


Popular Pytorch Projects
Popular Machine Learning Projects
Popular Machine Learning Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Python
Machine Learning
Deep Learning
Pytorch
Neural Network
Data Science
Keras