Helper to train deep neural networks
Reason this release was yanked:
Hidden incompatibilities with pytorch<2.3
Project description
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
# Datasets
trainset = #....
valset = #....
testset = #....
# Dataloaders
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)
# Model & device
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = #....
model.to(device)
# Optimizer & Scheduler
optimizer = torch.optim.Adam(model.parameters(), lr=0.001)
scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=len(trainset) * 50, 0.1) # Decay by 10 every 50 epochs
# Criterion
criterion = torch.nn.CrossEntropyLoss() # For classification for instance
# Training
trainer = PytorchTrainer(model, optimizer, scheduler, save_mode="small", device=device)
trainer.train(150, train_loader, criterion, val_loader=val_loader)
# Testing
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:
$ # See hyperparameters available
$ python example.py -h
$
$ # Launch the default training
$ python example.py
$
$ # Once done (or during the training), look for default tensorboard logs
$ tensorboard --logdir experiments/logs/
This script is reaching around 94-95% accuracy on validation with Cifar10 and a PreActResNet18.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deep_trainer-0.1.6.tar.gz.
File metadata
- Download URL: deep_trainer-0.1.6.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab5face3d586d60ce56638f225172289adf338f9e962b54974c91fb822e1b622
|
|
| MD5 |
3e1dac76e0acb351e562a82f9c313a4b
|
|
| BLAKE2b-256 |
d552026c3a0b7c227d6f8c2a952b8d6f1130353bfc3ac279894d0e980a6ee114
|
File details
Details for the file deep_trainer-0.1.6-py3-none-any.whl.
File metadata
- Download URL: deep_trainer-0.1.6-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1c77b8e1e11167a1e6bd2756a4afe30627a3f79d8807df6abd1b4ccea379ef4
|
|
| MD5 |
ea27cf4a5b6bafd3555b2bdac09d4fa0
|
|
| BLAKE2b-256 |
f931f58dd5d80c5f8eb8b8cc226a5da7b8c2ff8cb827fadf1c65d833c3c5eb25
|