All Projects → GRAAL-Research → Poutyne

GRAAL-Research / Poutyne

Licence: lgpl-3.0
A simplified framework and utilities for PyTorch

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Poutyne

Seglearn
Python module for machine learning time series:
Stars: ✭ 435 (-5.02%)
Mutual labels:  data-science
Food Recipe Cnn
food image to recipe with deep convolutional neural networks.
Stars: ✭ 448 (-2.18%)
Mutual labels:  data-science
Datasciencepython
common data analysis and machine learning tasks using python
Stars: ✭ 4,442 (+869.87%)
Mutual labels:  data-science
Numpycnn
Building Convolutional Neural Networks From Scratch using NumPy
Stars: ✭ 436 (-4.8%)
Mutual labels:  data-science
Spacy
💫 Industrial-strength Natural Language Processing (NLP) in Python
Stars: ✭ 21,978 (+4698.69%)
Mutual labels:  data-science
Tensor House
A collection of reference machine learning and optimization models for enterprise operations: marketing, pricing, supply chain
Stars: ✭ 449 (-1.97%)
Mutual labels:  data-science
Awesome Feature Engineering
A curated list of resources dedicated to Feature Engineering Techniques for Machine Learning
Stars: ✭ 433 (-5.46%)
Mutual labels:  data-science
Pyod
A Python Toolbox for Scalable Outlier Detection (Anomaly Detection)
Stars: ✭ 5,083 (+1009.83%)
Mutual labels:  data-science
Data Science Ipython Notebooks
Data science Python notebooks: Deep learning (TensorFlow, Theano, Caffe, Keras), scikit-learn, Kaggle, big data (Spark, Hadoop MapReduce, HDFS), matplotlib, pandas, NumPy, SciPy, Python essentials, AWS, and various command lines.
Stars: ✭ 22,048 (+4713.97%)
Mutual labels:  data-science
Courses
Quiz & Assignment of Coursera
Stars: ✭ 454 (-0.87%)
Mutual labels:  data-science
Teaching
Teaching Materials for Dr. Waleed A. Yousef
Stars: ✭ 435 (-5.02%)
Mutual labels:  data-science
Python Ml Course
Curso de Introducción a Machine Learning con Python
Stars: ✭ 442 (-3.49%)
Mutual labels:  data-science
Python Causality Handbook
Causal Inference for the Brave and True. A light-hearted yet rigorous approach to learning about impact estimation and sensitivity analysis.
Stars: ✭ 449 (-1.97%)
Mutual labels:  data-science
Awesome
Awesome resources on Bioinformatics, data science, machine learning, programming language (Python, Golang, R, Perl) and miscellaneous stuff.
Stars: ✭ 436 (-4.8%)
Mutual labels:  data-science
Serenata De Amor
🕵 Artificial Intelligence for social control of public administration
Stars: ✭ 4,367 (+853.49%)
Mutual labels:  data-science
Code search
Code For Medium Article: "How To Create Natural Language Semantic Search for Arbitrary Objects With Deep Learning"
Stars: ✭ 436 (-4.8%)
Mutual labels:  data-science
Turbodbc
Turbodbc is a Python module to access relational databases via the Open Database Connectivity (ODBC) interface. The module complies with the Python Database API Specification 2.0.
Stars: ✭ 449 (-1.97%)
Mutual labels:  data-science
Gop
GoPlus - The Go+ language for engineering, STEM education, and data science
Stars: ✭ 7,829 (+1609.39%)
Mutual labels:  data-science
Awesome Mlops
A curated list of references for MLOps
Stars: ✭ 7,119 (+1454.37%)
Mutual labels:  data-science
Caer
High-performance Vision library in Python. Scale your research, not boilerplate.
Stars: ✭ 452 (-1.31%)
Mutual labels:  data-science

Poutyne Logo

License: LGPL v3 Continuous Integration

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.6.

Cite

@misc{poutyne,
    author = {Paradis, Fr{\'e}d{\'e}rik and Beauchemin, David and Godbout, Mathieu and Alain, Mathieu and Garneau, Nicolas and Otte, Stefan and Tremblay, Alexis and B{\'e}langer, Marc-Antoine and Laviolette, Fran{\c{c}}ois},
    title  = {{Poutyne: A Simplified Framework for Deep Learning}},
    year   = {2020},
    note   = {\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

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'],
              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 that again also uses epoch metrics.

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 Experiment class that offers automatic checkpointing, logging and more using callbacks under the hood. Here is an example of usage.

from poutyne import Experiment, TensorDataset
from torch.utils.data import DataLoader

# We need to use dataloaders (i.e. an iterable of batches) with Experiment
train_loader = DataLoader(TensorDataset(train_x, train_y), batch_size=32)
valid_loader = DataLoader(TensorDataset(valid_x, valid_y), batch_size=32)
test_loader = DataLoader(TensorDataset(test_x, test_y), batch_size=32)

# Everything is saved in ./expt/my_classification_network
expt = Experiment('./expt/my_classification_network', network, device=device, optimizer='sgd', task='classif')

expt.train(train_loader, valid_loader, epochs=5)

expt.test(test_loader)

See the complete code here. Also, see this for an example for regression that again also uses epoch metrics.


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/[email protected]

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.


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]


Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].