Skip to content

Latest commit

 

History

History

sentence_classifier

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Sentence Sentiment Classifier

This example builds sentence convolutional classifier, and trains on SST data. The example configuration config_kim.py corresponds to the paper (Kim) Convolutional Neural Networks for Sentence Classification.

The example shows:

  • Contruction of simple model, involving the Embedder and Conv1DClassifier.
  • Use of Texar MultiAlignedData to read parallel text and label data.

Usage

Use the following command to download and prepare the SST binary data:

python sst_data_preprocessor.py --data-path ./data

Here

  • --data-path specifies the directory to store the SST data. If the data files do not exist, the program will automatically download, extract, and pre-process the data.

The following command trains the model with Kim's configuration:

python classifier_main.py --config config_kim

Here:

  • --config specifies the config file to use. E.g., the above use the configuration defined in config_kim.py

The model will begin training and evaluating on the validation data, and will evaluate on the test data after every epoch if a valid accuracy is obtained.

Results

The model achieves around 83% test set accuracy.