deep-trainer

Baseline code to train deep neural networks.
Currently only available for PyTorch Framework.
Install
Pip
$ pip install deep-trainer
Conda
Not yet available
Getting started
import torch
from deep_trainer import PytorchTrainer
trainset =
valset =
testset =
train_loader = torch.utils.data.DataLoader(trainset, 64, shuffle=True)
val_loader = torch.data.utils.DataLoader(valset, 256)
test_loader = torch.data.utils.DataLoader(testset, 256)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model =
model.to(device)
optimizer = torch.optim.Adam(model.parameters(), lr=0.001)
scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=len(trainset) * 50, 0.1)
criterion = torch.nn.CrossEntropyLoss()
trainer = PytorchTrainer(model, optimizer, scheduler, save_mode="small", device=device)
trainer.train(150, train_loader, criterion, val_loader=val_loader)
trainer.load("experiments/checkpoints/best.ckpt")
trainer.evaluate(test_loader, criterion)
Example
example/example.py
shows how to train a PreActResNet with Deep Trainer.
Install the additional requirements and use it with:
$
$ python example.py -h
$
$
$ python example.py
$
$
$ tensorboard --logdir experiments/logs/
This script is reaching around 94-95% accuracy on validation with Cifar10 and a PreActResNet18.