Simplified PyTorch Trainer
Project description
Torch-Tutor
GOALS of the Project
1. Reduces implementation time upto 50%.
2. Presents Eye-catching Training Job Monitor.
3. Stores training data efficiently.
4. Integrated with W&B.
Visit at PyPI
Primary Release
Installation
-
Primary Requirements :
a) Python >= 3.9
b) Torch >= 1.11.0 + cu113
Visit Custom Installation PyTorch to install the latest version(Date : 07-09-2022)
-
Install the
torch_tutorpackage.
Package Installation
a) From PyPi :
pip install torch_tutor
b) From Repository :
Install the reporsitory :
git clone https://github.com/sagnik1511/Torch-Tutor.git
Go to the directory.
cd Torch_Tutor
Install from the local repository.
pip install -v -e .
Usage
from torch_tutor.core.trainer import Trainer
from torch_tutor.core.callbacks import CallBack
callback = CallBack(tracker="accuracy",
stop_epoch=5,
save_weights=True,
on="training",
save_directory="../weight_directory")
trainer = Trainer(train_dataset="<add your train_dataset_here>",
model="<add your model here>",
device="cpu")
optimizer_hyperparameter_dict = {"lr" : 0.0001}
trainer.compile(optimizer="<add your optimizer here>",
loss_fn="<add your los function here>",
metrics=["accuracy", "precision",...],
optimizer_hparams=optimizer_hyperparameter_dict)
trainer.train(batch_size=32,
num_epochs=50,
training_steps=100,
validation_set="<add your validation dataset here>",
validation_steps=50,
logging_index=10,
shuffle=True,
drop_last_batches=True,
callback=callback,
connect_wandb=True,
exp_name="New Experiment")
Check in Google Colab
Feature Description
CallBack
from torch_tutor.core.callbacks import CallBack
tracker [type: list] : On which metric the model will be tested. Currently, supporting "accuracy", "precision", "recall", "f1_score" and "mean_squared_error".
stop_epoch [type: int] : Number of epochs of continuous degradation after training stops.
save_weights [type: bool] : Flag to save best model.
on [type: str] : On which dataset the best results will be tracked. Takes either "training" or "validation".
save_directory [type: Path] : On which directory the best model will be saved.
Trainer
from torch_tutor.core.trainer import Trainer
train_dataset [type: torch.utils.data.Dataset] : The dataset used for training.
model [type: torch.nn.Module] : The model used for training.
device [type: str] : The device used for training . Currently supporting cpu and cuda.
compile
optimizer : The optimizer which will be used for training, e.g. Adam, Adagrad
loss_fn : The loss function that is used for backpropagation, e.g. CrossEntropyLoss, MSELoss
metrics [type: str] : On which metric the model will be tested. Currently, supporting "accuracy", "precision", "recall", "f1_score" and "mean_squared_error".
optimizer_hparams [type: dict] : The parameters that are used inside Optimizer e.e learning_rate,weight_decay.
train
batch_size [type: int] : Batch size of the training and validation set.
num_epochs [type: int] : Number of epoch on which the model will be trained.
training_steps [type: int] : Number of batches per epoch on which model will be trained.
validation_set [type: None or torch.utils.data.Dataset] : On which the model will be validated.
validation_steps [type : int] : Number of batches per epoch on which model will be validated.
logging_index [type: int] : Number of indexes after which results will be shown.
shuffle [type: bool] : Flag to shuffle data indexes.
drop_last_batches [type: bool] : Flag on which the last small batches will be cut.
callback [type: torch_tutor.core.callback.callBack] : CallBack function.
connect_wandb [type: bool] : Flag to connect W&B loggers.
exp_name [type: str] : Name of the experiment.
Module Functionalities Achieved
-
Training through CPU / GPU / TPU.
-
Basic Loggings & Reports.
-
W&B Integration.
-
MLFlow Integration.
-
Distributed Training.
-
Multi-Model Training.
-
Effective Web-platform UI.
If you get any errors while running the code, please make a PR.
Thanks for Visiting!!!
If you like the project, do ⭐
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
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 torch_tutor-0.0.4.tar.gz.
File metadata
- Download URL: torch_tutor-0.0.4.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d601db32cebd65c8a2bcefcae3fe4b4468bdb5cd5694e6e764f572e821c2e7c
|
|
| MD5 |
974e176b0aaf8702891f6dadbc2eaeb4
|
|
| BLAKE2b-256 |
7b330c31da16538da230ef5cb9921bb752ab59187b6d97ab030ba0c144d9b852
|
File details
Details for the file torch_tutor-0.0.4-py3-none-any.whl.
File metadata
- Download URL: torch_tutor-0.0.4-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cfab5f7c8c30c65d2e6348a7ef4feaf2f229bdc039ea3f0f5fa701ad972dd30
|
|
| MD5 |
333f96dba5178a69ffb33df08d267ae2
|
|
| BLAKE2b-256 |
1bcf7d095e897aaa31d3499d6190575cce577843658508c85c987591e80996f8
|