Skip to content
A Keras-like framework and utilities for PyTorch
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Change multi-input to keep consistency Apr 18, 2019
examples Show the output of the examples Apr 18, 2019
poutyne Fix Model doc following the change of multi-input to keep consistency Apr 18, 2019
pytoune Change PyToune's name to Poutyne Mar 24, 2019
tests
.gitignore
.pylintrc
.travis.yml Use pytest instead of nose Aug 1, 2018
LICENSE Adding license file Feb 20, 2018
README.md Fix README following the change of multi-input to keep consistency Apr 18, 2019
requirements.txt Update version to v0.5 Mar 24, 2019
setup.cfg Update for new repo URL and PyPi Feb 20, 2018
setup.py Change PyToune's name to Poutyne Mar 24, 2019

README.md

Poutyne: Deep Learning framework for PyTorch

License: GPL v3 Build Status

Here is Poutyne.

As you can see, PyToune has changed its name for Poutyne. From now on, please use the new package name poutyne. The pytoune package has been kept for this release but will be removed in the next release.

Poutyne is a Keras-like 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.5.

Cite

@misc{frederikParadisPoutyne,
  author = {Paradis, Fr{\'e}d{\'e}rik and Garneau, Nicolas},
  title  = {{Poutyne}: Keras-like framework for {PyTorch}},
  year   = {2018--},
  url    = {\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.framework import Model
import torch
import numpy as np

num_features = 20
num_classes = 5

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')

Create yourself a PyTorch network;

pytorch_module = torch.nn.Linear(num_features, num_classes)

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

model = Model(pytorch_module, 'sgd', 'cross_entropy', metrics=['accuracy'])
model.fit(
    train_x, train_y,
    validation_data=(valid_x, valid_y),
    epochs=5,
    batch_size=32
  )

This is really similar to the model.compile function as in Keras;

# Keras way to compile and train
model.compile(loss='categorical_crossentropy',
              optimizer='sgd',
              metrics=['accuracy'])
model.fit(train_x, train_y, epochs=5, batch_size=32)

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

loss_and_metrics = model.evaluate(test_x, test_y)

Or only predict on new data;

predictions = model.predict(test_x)

As you can see, Poutyne is inspired a lot by the friendliness of Keras. See the Poutyne documentation at Poutyne.org for more.


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 version of Poutyne:
pip install -U git+https://github.com/GRAAL-Research/poutyne.git

Why this name, Poutyne?

Poutyne (or poutine in Québécois) is now the well-known dish from Quebec composed of French fries, squeaky cheese curds and brown gravy. However, in Quebec, it 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]


You can’t perform that action at this time.