# text_cnn_mr
## Synopsis
1. Use TextCNN model to achieve movie reviews binary classification;
2. Support pretrained word vector as embedding layer (using word2vec);
3. Supoort static and nonstatic embedding layer (by tensorflow parameter definition).
4. Support log train
## Environments
1. python3.5.2
2. tensorflow1.4.0
## Data Preprocess
1. Run `data_helper.py` to load pretrained word2vec model to build word embedding;
2. Parameter `w2v_flie` can be modified to change word2vec model path.
3. For me, I use model `GoogleNews-vectors-negative300.bin` here. [Baidu Yun Link](https://pan.baidu.com/s/1xX0U-Z4DGTCol1-BWN133g). Password:`zbiq`.
## Train Model
1. Run `train.py` with arguments `--word2vec/rand` and `--static/nonstatic`, and model will be saved at path `/runs/<timestamp>/checkpoints/`.
2. Argument `--word2vec` means using word2vec model as the initial value of embedding layer, `--rand` means initializing embedding layer randomly;
3. Arguments `--static` means embedding layer will not be updated when training, `--static` means updated.
## Evaluation
1. Run `eval.py` to evaluate model. The default config is to evaluate on training data. You can make your own testing data and modify the tf flags `eval_train` to evaluate model on testing data.
2. Argument `--checkpoint_dir` assign model's path, can be modified to use different trained model.
3. I trained 3 models (rand, word2vec-static, word2vec-nonstatic),each model was trained with 20 epochs. Their accuracy on training data was showed as follows:
| Rand | W2v-static | W2v-nonstatic |
| --- | --- | --- |
|97.477%|96.999%|97.533%|
## References
1. [Convolutional Neural Networks for Sentence Classification](https://arxiv.org/abs/1408.5882)
2. [dennybritz/cnn-text-classification-tf](https://github.com/dennybritz/cnn-text-classification-tf/)
3. [JianWenJun/MLDemo](https://github.com/JianWenJun/MLDemo/blob/master/NLP/Text_CNN/text_cnn_main.py)

霍姆格雷特
- 粉丝: 82
最新资源
- 基于PLC技术龙门式精密油压机电气设计方案探讨.doc
- (源码)基于Win32 API的试制小游戏.zip
- 互联网+背景下高中学生历史学科核心素养的培养初探.docx
- 网络存储产品在NVR系统中的应用-公共场所其他.docx
- 计算机维修电脑部件组成实训报告.doc
- (源码)基于KiCad和ESP32S3的心电图模拟数字转换系统.zip
- 使用纯 Python 编写机器学习算法的实现指南与示例
- 信息化校园建设.ppt
- 四层电梯的PLC控制.doc
- (源码)基于Pygame的推箱子游戏(Sokoban).zip
- 《flash8动画设计实例教程》第五章.ppt
- 软件开发项目初步验收专业技术方案.doc
- 工程项目管理2011年7月自考复习资料.doc
- (源码)基于lnArduino框架的红点焊接机控制板.zip
- XX年国家网络安全宣传周活动实施方案.docx
- (源码)基于Python和TensorFlow的以图搜图系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


