Skip to content

Pytorch / Tensorflow Implementation of Hierarchical Attention Networks for Document Classification

Notifications You must be signed in to change notification settings

SSinyu/Hierarchical-Attention-Networks

Repository files navigation

Hierarchical Attention Networks

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.

Requirements

  • Pytorch or Tensorflow, nltk, NumPy, pandas, matplotlib

Data

  • 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 ..."
... ...

Use

  1. Download sample_text.zip and unzip
  2. run python prep.py for text preprocessing
  3. run python pytorch_main.py or python tf_main.py for traning (check argument)
  4. run python pytorch_main.py --mode='test' --test_iters=***
    or python tf_main.py --mode='test' --test_iters=*** for test

Result

About

Pytorch / Tensorflow Implementation of Hierarchical Attention Networks for Document Classification

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages