Sentiment Analysis with Hierarchical Neural Networks - Pytorch flavor

This repository holds Pytorch (near)-implementations of the following papers:

Implementations are single-gpu batched.

Requirements:

Quickstart:

  1. chmod +x minimal_ex_cuda.sh
  2. ./minimal_ex_cuda.sh

Main Scripts:

Input formats:

Data input (filename argument)

han.py and nscupa.py expect a pickled dictionnary with the following keys as input:

input = {"data":data,"splits":splits,"rows":("user_id","item_id","review","rating")}

Where:

=> A helper script prepare_data.py is provided to create such input pickle file.

Pre-trained embeddings (emb optional argument)

han.py and nscupa.py can use pre-trained embedding. It expects a .txt where each line is a word followed by its vector. The first line of this file provides the number of words and the size of each vectors. BuildW2VEmb.py is provided to build word embeddings from data using the word2vec-skipgram algorithm.

If no pre-trained embeddings are provided han.py and nscupa.py build embedding dictionnaries and vectors on the fly (---max-feat arg).

Helper scripts

Note

This code has been written for python-3.6. If you are only using python-2.7, switch.