Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

inferno-pytorch/inferno

Folders and files

NameName
Last commit message
Last commit date

Latest commit

002cbe6 · Dec 25, 2018
Aug 24, 2017
Aug 15, 2018
Aug 15, 2018
Dec 19, 2018
Dec 25, 2018
Dec 20, 2018
Aug 24, 2017
Aug 24, 2017
Dec 25, 2018
Jun 7, 2018
Aug 15, 2018
Aug 15, 2018
Aug 24, 2017
Aug 24, 2017
Aug 24, 2017
Oct 8, 2018
Aug 24, 2017
Aug 15, 2018
Oct 4, 2017
Oct 4, 2017
Aug 15, 2018
Apr 23, 2018
Aug 28, 2017

Repository files navigation

Inferno

https://travis-ci.org/inferno-pytorch/inferno.svg?branch=master Documentation Status

Inferno is a little library providing utilities and convenience functions/classes around PyTorch. It's a work-in-progress, but the first stable release (0.2) is underway!

Features

Current features include:
import torch.nn as nn
from inferno.io.box.cifar import get_cifar10_loaders
from inferno.trainers.basic import Trainer
from inferno.trainers.callbacks.logging.tensorboard import TensorboardLogger
from inferno.extensions.layers.convolutional import ConvELU2D
from inferno.extensions.layers.reshape import Flatten

# Fill these in:
LOG_DIRECTORY = '...'
SAVE_DIRECTORY = '...'
DATASET_DIRECTORY = '...'
DOWNLOAD_CIFAR = True
USE_CUDA = True

# Build torch model
model = nn.Sequential(
    ConvELU2D(in_channels=3, out_channels=256, kernel_size=3),
    nn.MaxPool2d(kernel_size=2, stride=2),
    ConvELU2D(in_channels=256, out_channels=256, kernel_size=3),
    nn.MaxPool2d(kernel_size=2, stride=2),
    ConvELU2D(in_channels=256, out_channels=256, kernel_size=3),
    nn.MaxPool2d(kernel_size=2, stride=2),
    Flatten(),
    nn.Linear(in_features=(256 * 4 * 4), out_features=10),
    nn.LogSoftmax(dim=1)
)

# Load loaders
train_loader, validate_loader = get_cifar10_loaders(DATASET_DIRECTORY,
                                                    download=DOWNLOAD_CIFAR)

# Build trainer
trainer = Trainer(model) \
  .build_criterion('NLLLoss') \
  .build_metric('CategoricalError') \
  .build_optimizer('Adam') \
  .validate_every((2, 'epochs')) \
  .save_every((5, 'epochs')) \
  .save_to_directory(SAVE_DIRECTORY) \
  .set_max_num_epochs(10) \
  .build_logger(TensorboardLogger(log_scalars_every=(1, 'iteration'),
                                  log_images_every='never'),
                log_directory=LOG_DIRECTORY)

# Bind loaders
trainer \
    .bind_loader('train', train_loader) \
    .bind_loader('validate', validate_loader)

if USE_CUDA:
  trainer.cuda()

# Go!
trainer.fit()

To visualize the training progress, navigate to LOG_DIRECTORY and fire up tensorboard with

$ tensorboard --logdir=${PWD} --port=6007

and navigate to localhost:6007 with your browser.

Installation

Conda packages for linux (only python 3) are available via

$ conda install -c pytorch -c conda-forge inferno

Future Features:

Planned features include:
  • a class to encapsulate Hogwild! training over multiple GPUs,
  • minimal shape inference with a dry-run,
  • proper packaging and documentation,
  • cutting-edge fresh-off-the-press implementations of what the future has in store. :)

Credits

All contributors are listed here_. .. _here: https://inferno-pytorch.github.io/inferno/html/authors.html

This package was partially generated with Cookiecutter and the audreyr/cookiecutter-pypackage project template + lots of work by Thorsten.