Pytorch/Tensorflow implementation of Hierarchical Attention Networks for Document Classification.
Model has a hierarchical structure that mirrors the hierarchical structure of documents, and consist of word-level encoder/attention layer, sentence-level encoder/attention layer.
- Pytorch or Tensorflow, nltk, NumPy, pandas, matplotlib
- Sample_text.zip (Sample_text.csv)
- Data consist of 100,000 reviews and stars.
class | text |
---|---|
4 | "It was a great experience. They helped us ... " |
5 | "Amazing service to use for removing junk ..." |
1 | "Good little cafe in Matthews. I tried the ..." |
... | ... |
- Download sample_text.zip and unzip
- run
python prep.py
for text preprocessing - run
python pytorch_main.py
orpython tf_main.py
for traning (check argument) - run
python pytorch_main.py --mode='test' --test_iters=***
orpython tf_main.py --mode='test' --test_iters=***
for test