Git Product home page Git Product logo

pytoune's Introduction

PyToune: Deep Learning framework for PyTorch

License: GPL v3 Build Status

Here is PyToune.

PyToune is a Keras-like framework for PyTorch and handles much of the boilerplating code needed to train neural networks.

Use PyToune to:

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

Read the documentation at PyToune.org.

PyToune is compatible with PyTorch >= 0.3.0 and Python >= 3.5.


Getting started: few seconds to PyToune

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

How PyToune 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 PyToune Model, which handles all the steps, stats and callbacks, similar to what Keras does.

Here is a simple example:

# Import the PyToune Model and define a toy dataset
from pytoune.framework import Model

num_train_samples = 800
train_x = torch.rand(num_train_samples, num_features)
train_y = torch.rand(num_train_samples, 1)

num_valid_samples = 200
valid_x = torch.rand(num_valid_samples, num_features)
valid_y = torch.rand(num_valid_samples, 1)

Create yourself a PyTorch network, a loss function and an optimizer;

pytorch_module = torch.nn.Linear(num_features, 1)
loss_function = torch.nn.MSELoss()
optimizer = torch.optim.SGD(pytorch_module.parameters(), lr=1e-3)

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

model = Model(pytorch_module, optimizer, loss_function)
model.fit(
    train_x, train_y,
    validation_x=valid_x,
    validation_y=valid_y,
    epochs=num_epochs,
    batch_size=batch_size
  )

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(x_train, y_train, epochs=5, batch_size=32)

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

loss_and_metrics = model.evaluate(x_test, y_test)

Or only predict on new data;

predictions = model.predict(x_test)

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


Installation

Before installing PyToune, you must have a working version of PyTorch 0.3.0 in your environment.

  • Install the stable version of PyToune:
pip install pytoune
  • Install the latest version of PyToune:
pip install -U git+https://github.com/GRAAL-Research/pytoune.git

Why this name, PyToune?

PyToune (or pitoune in Québécois) used to be wood logs that flowed through the rivers. It was an efficient way to travel large pieces of wood across the country. We hope that PyToune will make your PyTorch neural networks training flow easily just like the "pitounes" used to.

Pitounes


pytoune's People

Contributors

freud14 avatar gletarte avatar jsleb333 avatar ngarneau avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.