This is simpliest and useful train loop for pytorch. You can easy train your model on any dataset and dataloader.
git clone https://github.com/alxmamaev/theloop
cd theloop
python setup.py install
- CIFAR10 example
- IMDB example (in progress)
- Metric learning example (in progress)
- Autoencoder example (in progress)
_____ _______ _____ _______ _______ _ _ ______ _ ____ ____ _____
/ ____|__ __|/\ | __ \__ __| |__ __| | | | ____| | / __ \ / __ \| __ \
| (___ | | / \ | |__) | | | | | | |__| | |__ | | | | | | | | | |__) |
\___ \ | | / /\ \ | _ / | | | | | __ | __| | | | | | | | | | ___/
____) | | |/ ____ \| | \ \ | | | | | | | | |____| |___| |__| | |__| | |
|_____/ |_/_/ \_\_| \_\ |_| |_| |_| |_|______|______\____/ \____/|_|
EXPERIMENT NAME: experiment
EXPERIMENT ID: 4364
NUM EPOCH: 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ̄ ̄ ̄ ̄ ̄ ̄|
EPOCH: 0
|______|
(\__/) ||
(•ㅅ•) ||
/ づ
BATCH 1562; ITER 1562: 100%|██████████| 1563/1563 [03:59<00:00, 3.99s/it, loss=1.63]
+-------------------+
| EPOCH METRICS |
+----------+--------+
| Metric | Vlaue |
+----------+--------+
| accuracy | 0.6173 |
+----------+--------+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ̄ ̄ ̄ ̄ ̄ ̄|
THE END
|______|
(\__/) ||
(•ㅅ•) ||
/ づ
+-------------------+
| BEST METRICS |
+----------+--------+
| Metric | Vlaue |
+----------+--------+
| accuracy | 0.6914 |
+----------+--------+
- Cool logs 😎
- Tensorboard logging
- Checkpoint saving
- Validation
- Selecting the best checkpoint
- Scheduler support
- Tqdm notebook support
- Early stopping by
^C
model
- your nn.Module modelcriterion
- string with name of loss or loss classbatch_callback
- function of batch callback (look a examples)val_callback
- function of batch callback (look a examples)optimizer
- string with name of optimizer or optimizer classoptimizer_param
- dict of key-value parameters that will be push into optimizerscheduler
- string with name of scheduler or scheduler classscheduler_params
- dict of key-value parameters that will be push into schedulerdevice
- string with name of acceleration device (default "cpu")val_rate
- int rate of iteration when validation was startinglogdir
- string path to log directoryname
- string name of your experimentloss_key
- string key of loss in dict returned by batch_callbackval_criterion_key
- string key of validation in dict returned by val_callbackval_criterion_mode
- string mode of selecting best checkpoint ("max" or "min")use_best_model
- bool use best (by validation metric) model as final modeluse_tqdm_notebook
- bool use tqdm_notebook instead tqdm
Train model from dataset
train_dataset
- torch Dataset for trainingval_dataset
- torch Dataset for validationbatch_size
- int batch sizen_workers
- int number of workersshuffle
- bool shuffle datasetn_epoch
- int number of epoch
Train model from dataloader
train_dataloader
- torch DataLoader for trainingval_dataloader
- torch DataLoader for validationn_epoch
- int number of epoch
- Early stopping by validation metrics
- Pushing images to Tensorboard
- Data parallel