资源算法poutyne

poutyne

2019-10-09 | |  169 |   0 |   0

poutyne-dark.png

License: GPL v3 Build Status

Here is Poutyne.

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{poutyne,
    author = {Paradis, Fr{'e}d{'e}rik},
    title  = {{Poutyne: A Keras-like framework for PyTorch}},
    year   = {2018},
    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 datasetfrom poutyne.framework import Modelimport torchimport numpy as np

num_features = 20num_classes = 5num_train_samples = 800train_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 = 200valid_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 = 200test_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',              batch_metrics=['accuracy'], epoch_metrics=['f1'])
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 and model.fit functions as in Keras.

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 development version of Poutyne:

pip install -U git+https://github.com/GRAAL-Research/poutyne.git@dev

Examples

Look at notebook files with full working examples:


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 GPLv3 licensed, as found in the LICENSE file.


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.

68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f342f34652f4c615f42616e71756973655f506f7574696e655f25323863726f707065642532392e6a7067.jpg Yuri Long from Arlington, VA, USA [CC BY 2.0]


上一篇:extension-cpp

下一篇:jetson-reinforcement

用户评价
全部评价

热门资源

  • Keras-ResNeXt

    Keras ResNeXt Implementation of ResNeXt models...

  • seetafaceJNI

    项目介绍 基于中科院seetaface2进行封装的JAVA...

  • spark-corenlp

    This package wraps Stanford CoreNLP annotators ...

  • capsnet-with-caps...

    CapsNet with capsule-wise convolution Project ...

  • inferno-boilerplate

    This is a very basic boilerplate example for pe...