# deep-trainer
[](https://github.com/raphaelreme/deep-trainer/actions/workflows/tests.yml)
Baseline code to train deep neural networks.
Currently only available for PyTorch Framework.
## Install
### Pip
```bash
$ pip install deep-trainer
```
### Conda
Not yet available
## Getting started
```python
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:
```bash
$ # 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/raphaelreme/deep-trainer",
"name": "deep-trainer",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "deep learning, pytorch",
"author": "Raphael Reme",
"author_email": "raphaelreme-dev@protonmail.com",
"download_url": "https://files.pythonhosted.org/packages/18/c2/abbd83493d888b90bd9f821eb3d1532487794f51f18f9fa8f8eb982475f2/deep_trainer-0.1.7.tar.gz",
"platform": null,
"description": "# deep-trainer\n\n[](https://github.com/raphaelreme/deep-trainer/actions/workflows/tests.yml)\n\nBaseline code to train deep neural networks.\nCurrently only available for PyTorch Framework.\n\n\n## Install\n\n### Pip\n\n```bash\n$ pip install deep-trainer\n```\n\n### Conda\n\nNot yet available\n\n\n## Getting started\n\n```python\nimport torch\nfrom deep_trainer import PytorchTrainer\n\n\n# Datasets\ntrainset = #....\nvalset = #....\ntestset = #....\n\n# Dataloaders\ntrain_loader = torch.utils.data.DataLoader(trainset, 64, shuffle=True)\nval_loader = torch.data.utils.DataLoader(valset, 256)\ntest_loader = torch.data.utils.DataLoader(testset, 256)\n\n# Model & device\ndevice = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\nmodel = #....\nmodel.to(device)\n\n# Optimizer & Scheduler\noptimizer = torch.optim.Adam(model.parameters(), lr=0.001)\nscheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=len(trainset) * 50, 0.1) # Decay by 10 every 50 epochs\n\n# Criterion\ncriterion = torch.nn.CrossEntropyLoss() # For classification for instance\n\n# Training\ntrainer = PytorchTrainer(model, optimizer, scheduler, save_mode=\"small\", device=device)\ntrainer.train(150, train_loader, criterion, val_loader=val_loader)\n\n# Testing\ntrainer.load(\"experiments/checkpoints/best.ckpt\")\ntrainer.evaluate(test_loader, criterion)\n```\n\n\n## Example\n\n`example/example.py` shows how to train a PreActResNet with Deep Trainer.\n\nInstall the additional requirements and use it with:\n\n```bash\n$ # See hyperparameters available\n$ python example.py -h\n$\n$ # Launch the default training\n$ python example.py\n$\n$ # Once done (or during the training), look for default tensorboard logs\n$ tensorboard --logdir experiments/logs/\n```\n\nThis script is reaching around 94-95% accuracy on validation with Cifar10 and a PreActResNet18.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Helper to train deep neural networks",
"version": "0.1.7",
"project_urls": {
"Homepage": "https://github.com/raphaelreme/deep-trainer"
},
"split_keywords": [
"deep learning",
" pytorch"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "10c9f8906c1ab79feb9240c9371a17eb5b6401851caa08d218d810b392f6836e",
"md5": "afde186cfcc11387efb18c7601e99c66",
"sha256": "218bbef067763a51919ee49734c44ee04f6dc1e32b29602b7195fc946c0b9a48"
},
"downloads": -1,
"filename": "deep_trainer-0.1.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "afde186cfcc11387efb18c7601e99c66",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 15490,
"upload_time": "2025-10-20T17:24:37",
"upload_time_iso_8601": "2025-10-20T17:24:37.820933Z",
"url": "https://files.pythonhosted.org/packages/10/c9/f8906c1ab79feb9240c9371a17eb5b6401851caa08d218d810b392f6836e/deep_trainer-0.1.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "18c2abbd83493d888b90bd9f821eb3d1532487794f51f18f9fa8f8eb982475f2",
"md5": "b49cd6c600eaf9d4da29c3f9fb7493cd",
"sha256": "8a80c20607daf1c28a4f328c3875f8e8c507ec1bb2a5f0edf234842243b15c37"
},
"downloads": -1,
"filename": "deep_trainer-0.1.7.tar.gz",
"has_sig": false,
"md5_digest": "b49cd6c600eaf9d4da29c3f9fb7493cd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 14728,
"upload_time": "2025-10-20T17:24:38",
"upload_time_iso_8601": "2025-10-20T17:24:38.664717Z",
"url": "https://files.pythonhosted.org/packages/18/c2/abbd83493d888b90bd9f821eb3d1532487794f51f18f9fa8f8eb982475f2/deep_trainer-0.1.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-20 17:24:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "raphaelreme",
"github_project": "deep-trainer",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "deep-trainer"
}