EdGENetworks/attention-networks-for-classification
소개
PyTorch 기반 문서 분류용 계층적 어텐션 네트워크
시스템 및 인프라측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- -1
- in 1 month
- 0
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalHierarchical Attention Networks for Document Classification
We know that documents have a hierarchical structure, words combine to form sentences and sentences combine to form documents. We can try to learn that structure or we can input this hierarchical structure into the model and see if it improves the performance of existing models. This paper exploits that structure to build a classification model.
This is an (close) implementation of the model in PyTorch.
Note:
- I jointly optimize both the word and sentence attention models with the same optimizer.
- The minibatches are padded with zeros. This can be improved, one can sort senteces with similar length together, and minimize the paddings.
- Pytorch does not yet support gradient masking, so padded zeros will have gradients flowing through them during backpropagation. One can create a mask, but since I am interested in using Bidirectional GRU, it is not possible to use a mask. I've seen that variable length RNN supoort is coming soon to Pytorch as well. Update: Pytorch does supoort masked RNN now with pack_padded_sequence method.
This picture from Explosion blog explains the structure perfectly.

Notebook
The notebook contains an example of trained model on IMDB movie review dataset. I could not get the original IMDB dataset that the paper referred to, so I have used this data
The preprocessed data is available here
The best accuracy that I got was around ~ 0.35. This dataset has only 84919 samples and 10 classes. Here is the training loss for the dataset.

관련 프로젝트 살펴보기
불러오는 중…