Pytorch starter kit for Kaggle competitions
Pytorch Kaggle starter is a framework for managing experiments in Kaggle competitions. It reduces time to first submission by providing a suite of helper functions for model training, data loading, adjusting learning rates, making predictions, ensembling models, and formatting submissions.
Inside are example Jupyter notebooks walking through how to get strong scores on popular competitions:
These notebooks outline basic, single-model submissions. Scores can be improved significantly by ensembling models and using test-time augmentation.
pip install -r requirements.txt
To get started you'll need to move all training and test images to the project_root/datasets/inputs
directory (then either trn_jpg tst_jpg subdirectories). Running the first cell of each notebook creates the directory structure outlined in the config.py
file.
There is no need to create separate directories for classes or validation sets. This is handled by the data_fold.py module and the FileDataset, which expects a list of filepaths and targets. After trying out a lot of approaches, I found this to be the easiest and most extensible. You'll sometimes need to generate a metadata.csv
file separately if Kaggle didn't provide one. This sort of competition-specific code can live in the competitions/
directory.
Visualize experiment progress on your phone with Facebook's new Visdom framework.
Spin up an Elasticsearch cluster locally or on AWS to start visualizing or tracking experiments. Create custom dashboards with Kibana's easy-to-use drag and drop chart creation tools.
Filter and sort experiments, zoom to a specific time period, or aggregate metrics across experiments and see updates in real time.
Receive emails when experiments compete or fail using AWS SES service.
Quickly download and submit with the kaggle cli tool.
kg download -c dogs-vs-cats-redux-kernels-edition -v -u USERNAME -p PASSWORD
kg submit -m 'my sub' -c dogs-vs-cats-redux-kernels-edition -v -u USERNAME -p PASSWORD my_exp_tst.csv
Run tests with:
python -m pytest tests/
Other run commands:
python -m pytest tests/ (all tests)
python -m pytest -k filenamekeyword (tests matching keyword)
python -m pytest tests/utils/test_sample.py (single test file)
python -m pytest tests/utils/test_sample.py::test_answer_correct (single test method)
python -m pytest --resultlog=testlog.log tests/ (log output to file)
python -m pytest -s tests/ (print output to console)