Dxzmpk
In this article, we present you a deep learning project called Pytorch Sentiment Classification. I will use the method proposed in <<Kim Y. Convolutional Neural Networks for Sentence Classification. 2014>>
- modularity: we split each logic piece into a different python submodule
- ready to go: by using poutyne a Keras-like framework you don't have to write any train loop.
- torchsummary to show a summary of your models
- reduce the learning rate on a plateau
- auto-saving the best model
- experiment tracking with comet
- logging using python logging module
Clone the repo and go inside it. Then, run:
pip install -r requirements.txt
python train.py
don't forget to download nltk_data for yourself, or the program will report an error
In our case we kept things simple, all the training and evaluation logic is inside .main.py
where we used poutyne as the main library. We already defined a useful list of callbacks:
You may need to create custom callbacks, with poutyne is very easy since it support Keras-like API. You custom callbacks should go inside ./callbacks
. For example, we have created one to update Comet every epoch.
We are using comet to automatically track our models' results. This is what comet's board looks like after a few models run.
Running main.py
produces the following output:
I hope you found some useful information and hopefully it this template will help you on your next amazing project :)