Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.0%) to scientific vocabulary
Keywords
Repository
A simplified framework and utilities for PyTorch
Basic Info
- Host: GitHub
- Owner: GRAAL-Research
- License: lgpl-3.0
- Language: Python
- Default Branch: master
- Homepage: https://poutyne.org
- Size: 17.6 MB
Statistics
- Stars: 575
- Watchers: 15
- Forks: 65
- Open Issues: 8
- Releases: 39
Topics
Metadata Files
README.md

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, Frédérik and Beauchemin, David and Godbout, Mathieu and Alain, Mathieu and Garneau, Nicolas and Otte, Stefan and Tremblay, Alexis and Bélanger, Marc-Antoine and Laviolette, François},
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:
```python
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
numfeatures = 20 numclasses = 5 hiddenstatesize = 100
numtrainsamples = 800 trainx = np.random.randn(numtrainsamples, numfeatures).astype('float32') trainy = np.random.randint(numclasses, size=numtrainsamples).astype('int64')
numvalidsamples = 200 validx = np.random.randn(numvalidsamples, numfeatures).astype('float32') validy = np.random.randint(numclasses, size=numvalidsamples).astype('int64')
numtestsamples = 200 testx = np.random.randn(numtestsamples, numfeatures).astype('float32') testy = np.random.randint(numclasses, size=numtestsamples).astype('int64') ```
Select a PyTorch device so that it runs on GPU if you have one:
python
cuda_device = 0
device = torch.device("cuda:%d" % cuda_device if torch.cuda.is_available() else "cpu")
Create yourself a PyTorch network:
python
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:
python
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:
python
loss, (accuracy, f1score) = model.evaluate(test_x, test_y)
Or only predict on new data:
python
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.
```python from poutyne import ModelBundle
Everything is saved in ./saves/myclassificationnetwork
modelbundle = ModelBundle.fromnetwork( './saves/myclassificationnetwork', network, optimizer='sgd', task='classif', device=device )
modelbundle.traindata(trainx, trainy, validationdata=(validx, valid_y), epochs=5)
modelbundle.testdata(testx, testy) ```
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:
sh
pip install poutyne
- Install the latest development version of Poutyne:
sh
pip install -U git+https://github.com/GRAAL-Research/poutyne.git@dev
- Install and develop on top of the provided Docker Image
sh
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:
- introduction.ipynb (tutorial version) - comparison of Poutyne with bare PyTorch and usage examples of Poutyne callbacks and the ModelBundle class.
- tipsandtricks.ipynb - tips and tricks using Poutyne
- sequence_tagging.ipynb - Sequence tagging with an RNN
- transfer_learning.ipynb - transfer learning on
ResNet-18on the CUB-200 dataset. - policy_interface.ipynb - example of policies
- image_reconstruction.ipynb - example of image reconstruction
- classificationandregression.ipynb - example of multitask learning with classification and regression
- semantic_segmentation.ipynb - example of semantic segmentation
or in Google Colab:
- introduction.ipynb (tutorial version) - comparison of Poutyne with bare PyTorch and usage examples of Poutyne callbacks and the ModelBundle class.
- tipsandtricks.ipynb - tips and tricks using Poutyne
- sequence_tagging.ipynb - Sequence tagging with an RNN
- transfer_learning.ipynb - transfer learning on
ResNet-18on the CUB-200 dataset. - policy_interface.ipynb - example of policies
- image_reconstruction.ipynb - example of image reconstruction
- classificationandregression.ipynb - example of multitask learning with classification and regression
- semantic_segmentation.ipynb - example of semantic segmentation
Videos
- Presentation on Poutyne given at one of the weekly presentations of the Institute Intelligence and Data (IID) of Université Laval. Slides and the associated Latex source code are also available.
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 Frédérik 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.
Yuri Long from Arlington, VA, USA [CC BY 2.0]
Owner
- Name: GRAAL/GRAIL
- Login: GRAAL-Research
- Kind: organization
- Location: Québec, QC
- Website: grail.ift.ulaval.ca
- Repositories: 24
- Profile: https://github.com/GRAAL-Research
Machine Learning Research Group - Université Laval
Citation (CITATION.cff)
cff-version: 1.2.0
preferred-citation:
type: misc
message: "If you use Poutyne, please cite it as below."
authors:
- family-names: "Paradis"
given-names: "Frédérik"
- family-names: "Beauchemin"
given-names: "David"
- family-names: "Godbout"
given-names: "Mathieu"
- family-names: "Alain"
given-names: "Mathieu"
- family-names: "Garneau"
given-names: "Nicolas"
- family-names: "Otte"
given-names: "Stefan"
- family-names: "Tremblay"
given-names: "Alexis"
- family-names: "Bélanger"
given-names: "Marc-Antoine"
- family-names: "Laviolette"
given-names: "François"
title: "Poutyne: A Simplified Framework for Deep Learning"
url: "https://poutyne.org"
year: 2020
GitHub Events
Total
- Release event: 2
- Watch event: 5
- Issue comment event: 10
- Push event: 16
- Pull request review comment event: 3
- Pull request review event: 4
- Pull request event: 6
- Fork event: 2
- Create event: 3
Last Year
- Release event: 2
- Watch event: 5
- Issue comment event: 10
- Push event: 16
- Pull request review comment event: 3
- Pull request review event: 4
- Pull request event: 6
- Fork event: 2
- Create event: 3
Dependencies
- sphinx *
- sphinx_rtd_theme *
- colorama *
- fasttext *
- requests *
- torchmetrics *
- torchvision *
- colorama *
- mlflow *
- pandas *
- scikit-learn *
- tensorboard *
- tensorboardX *
- torchvision *
- numpy *
- torch *
- torchmetrics *
- numpy *
- torch *
- torchmetrics *
- black *
- flake8 ==4.0.1
- pylint ==2.12.1
- colorama * test
- matplotlib * test
- mlflow * test
- omegaconf * test
- pandas * test
- pillow * test
- pytest * test
- pytest-cov * test
- scikit-learn * test
- tensorboard * test
- tensorboardX * test
- torchmetrics * test
- torchvision * test
- wandb * test
- actions/checkout v3 composite
- actions/setup-python v4 composite
- peaceiris/actions-gh-pages 068dc23d9710f1ba62e86896f84735d869951305 composite
- actions/checkout v3 composite
- docker/build-push-action ad44023a93711e3deb337508980b4b5e9bcdc5dc composite
- docker/login-action f054a8b539a109f9f41c372932f1ae047eff08c9 composite
- docker/metadata-action 98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 composite
- actions/checkout v3 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- codecov/codecov-action v3 composite
- pytorch/pytorch 1.11.0-cuda11.3-cudnn8-runtime build