Skip to content
Devashish Shankar edited this page Oct 21, 2015 · 3 revisions

First ensure, you have all the dependencies installed, and word vectors downloaded by visiting the Setting page

Train

python train.py <model config file path> <training data file path> <file path to store classifier model> <true/false(preprocessing flag)>

To train a toy model on a sample dataset run:

python train.py sample/configs/sampleStaticConfig.json sample/datasets/sst_small_sample.csv sample/myFirstModel.p true

If this doesn't work, please go the Setting Up page, to ensure you have the dependencies installed. Also run the test cases in the test directory. We've placed the configs that worked best for us on a variety of tasks in the directory sample/configs. Feel free to experiment with them.

Test

python testing.py <model file path> <testing file path> <folder to store detailed output analysis> <preprocess? (true/false)> <load word vectors? (true/false)>

To test the model you trained above, you can run:

python test.py sample/myFirstModel.p sample/datasets/sst_small_sample.csv sample/outputNonStatic true false

This will print the accuracy/F-Score of the model and the detailed output will be in sample/outputNonStatic.

Deploy

python server.py <port number to deploy the app> <enable flask debug mode (true/false). > <load word vectors in memory (true/false)

To query the above model using an API, first start the server:

python server.py 1111 false false

To query the above model, paste the following on your web browser:

http://localhost:1111/?preprocess=true&model=sample/myFirstModel.p&text=this+is+the+worst+possible+movie+you+suck

Congratulations!

You have now successfully trained a toy CNN. Visit the User Guide to learn how to train your own datasets.

Clone this wiki locally