Code of Tree communication model (TCM) for sentiment analysis.
- python3
- tensorflow
- fold
cd data/trees
wget http://nlp.stanford.edu/~socherr/stanfordSentimentTreebank.zip
unzip stanfordSentimentTreebank.zip
rm stanfordSentimentTreebank.zip
- Specify Model: config.py --> 'model4test'
- Run the script:
# specify gpu in run.sh
./run.sh test_new.py
- If there is
Variable cannot found
error, please change the variable name of checkpoint accordingly.tools/rename_model.sh
is a script for variable rename of checkpoints:
# the output model is saved in the same directory as model_to_save: model_to_save_new
rename_model.sh model_to_reloade
- In saved_model/, we release our models under 4 settings.
- Obtain initial state from tree-LSTM. We take the tensorflow-fold impletation of tree-LSTM following sentiment.ipynb.
- Specify initial sate in config.py: 'pre_train'
- Start to Train:
# specify gpu in run.sh
./run.sh train_new.py
Please cite our ACL 2019 paper:
@inproceedings{zhang2019tree,
title = "Tree Communication Models for Sentiment Analysis",
author={Zhang, Yuan and Zhang, Yue},
booktitle = "Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics",
month = jul,
year = "2019",
address = "Florence, Italy",
publisher = "Association for Computational Linguistics",
pages = "3518--3527",
}