Skip to main content

Library build on top of pytorch to fuel productivity

Project description

torchfuel

Build Status codecov

Build on top of pytorch to fuel productivity.

Features

  • Generic Trainer
  • Classification Trainer (with cross-entropy loss)
  • MSE Trainer
  • Additional utility layers
  • Better dataloaders (currently only for image datasets)

Classification Example

import os
import time
from collections import namedtuple

import torch
import torch.nn as nn
import torch.optim as optim
from torch.optim import lr_scheduler
from torchvision import datasets, models, transforms

from torchfuel.data_loaders.image import ImageDataLoader
from torchfuel.trainers.classification import ClassificationTrainer
from torchfuel.transforms.noise import DropPixelNoiser


dl = ImageDataLoader(
    train_data_folder='imgs/train',
    eval_data_folder='imgs/eval',
    pil_transformations=[transforms.RandomHorizontalFlip()]
    tensor_transformations=[DropPixelNoiser()],
    batch_size=64,
    imagenet_format=True,
)

train_dataloader, eval_dataloader, n_classes = dl.prepare()

device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')

model = Model(...).to(device)

optimiser = optim.SGD(model.parameters(), lr=0.01, momentum=0.9)

scheduler = optim.lr_scheduler.ReduceLROnPlateau(optimiser, 'min', patience=20)

trainer = ClassificationTrainer(device, model, optimiser, scheduler)

fitted_model = trainer.fit(epochs, train_dataloader, eval_dataloader)

How to install

Clone repository and run:

pip install .

Optionally (not up to date):

pip install torchfuel

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchfuel-0.1.2.tar.gz (11.0 kB view hashes)

Uploaded Source

Built Distribution

torchfuel-0.1.2-py3-none-any.whl (19.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page