All Projects → datalogue → Keras Attention

datalogue / Keras Attention

Licence: agpl-3.0
Visualizing RNNs using the attention mechanism

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Keras Attention

Simplednn
SimpleDNN is a machine learning lightweight open-source library written in Kotlin designed to support relevant neural network architectures in natural language processing tasks
Stars: ✭ 81 (-88.38%)
Mutual labels:  natural-language-processing, recurrent-neural-networks, attention-mechanism
Sangita
A Natural Language Toolkit for Indian Languages
Stars: ✭ 43 (-93.83%)
Mutual labels:  natural-language-processing, deep-neural-networks, recurrent-neural-networks
Attention Mechanisms
Implementations for a family of attention mechanisms, suitable for all kinds of natural language processing tasks and compatible with TensorFlow 2.0 and Keras.
Stars: ✭ 203 (-70.88%)
Mutual labels:  natural-language-processing, recurrent-neural-networks, attention-mechanism
Ner Lstm
Named Entity Recognition using multilayered bidirectional LSTM
Stars: ✭ 532 (-23.67%)
Mutual labels:  natural-language-processing, deep-neural-networks, recurrent-neural-networks
Sockeye
Sequence-to-sequence framework with a focus on Neural Machine Translation based on Apache MXNet
Stars: ✭ 990 (+42.04%)
Mutual labels:  translation, deep-neural-networks, attention-mechanism
Awesome Distributed Deep Learning
A curated list of awesome Distributed Deep Learning resources.
Stars: ✭ 277 (-60.26%)
Mutual labels:  natural-language-processing, deep-neural-networks
Attention is all you need
Transformer of "Attention Is All You Need" (Vaswani et al. 2017) by Chainer.
Stars: ✭ 303 (-56.53%)
Mutual labels:  deep-neural-networks, attention-mechanism
Bytenet Tensorflow
ByteNet for character-level language modelling
Stars: ✭ 319 (-54.23%)
Mutual labels:  natural-language-processing, deep-neural-networks
Action Recognition Visual Attention
Action recognition using soft attention based deep recurrent neural networks
Stars: ✭ 350 (-49.78%)
Mutual labels:  deep-neural-networks, attention-mechanism
automatic-personality-prediction
[AAAI 2020] Modeling Personality with Attentive Networks and Contextual Embeddings
Stars: ✭ 43 (-93.83%)
Mutual labels:  recurrent-neural-networks, attention-mechanism
Ai Deadlines
⏰ AI conference deadline countdowns
Stars: ✭ 3,852 (+452.65%)
Mutual labels:  natural-language-processing, deep-neural-networks
Rmdl
RMDL: Random Multimodel Deep Learning for Classification
Stars: ✭ 375 (-46.2%)
Mutual labels:  deep-neural-networks, recurrent-neural-networks
Recurrent Entity Networks
TensorFlow implementation of "Tracking the World State with Recurrent Entity Networks".
Stars: ✭ 276 (-60.4%)
Mutual labels:  natural-language-processing, recurrent-neural-networks
Da Rnn
📃 **Unofficial** PyTorch Implementation of DA-RNN (arXiv:1704.02971)
Stars: ✭ 256 (-63.27%)
Mutual labels:  recurrent-neural-networks, attention-mechanism
Zhihu
This repo contains the source code in my personal column (https://zhuanlan.zhihu.com/zhaoyeyu), implemented using Python 3.6. Including Natural Language Processing and Computer Vision projects, such as text generation, machine translation, deep convolution GAN and other actual combat code.
Stars: ✭ 3,307 (+374.46%)
Mutual labels:  natural-language-processing, recurrent-neural-networks
pynmt
a simple and complete pytorch implementation of neural machine translation system
Stars: ✭ 13 (-98.13%)
Mutual labels:  translation, attention-mechanism
Transformer
A TensorFlow Implementation of the Transformer: Attention Is All You Need
Stars: ✭ 3,646 (+423.1%)
Mutual labels:  translation, attention-mechanism
Neuronlp2
Deep neural models for core NLP tasks (Pytorch version)
Stars: ✭ 397 (-43.04%)
Mutual labels:  natural-language-processing, deep-neural-networks
D2l Vn
Một cuốn sách tương tác về học sâu có mã nguồn, toán và thảo luận. Đề cập đến nhiều framework phổ biến (TensorFlow, Pytorch & MXNet) và được sử dụng tại 175 trường Đại học.
Stars: ✭ 402 (-42.32%)
Mutual labels:  translation, natural-language-processing
Awesome Bert Nlp
A curated list of NLP resources focused on BERT, attention mechanism, Transformer networks, and transfer learning.
Stars: ✭ 567 (-18.65%)
Mutual labels:  natural-language-processing, attention-mechanism

Status: Reference code only. No updates expected.

Attention RNNs in Keras

Implementation and visualization of a custom RNN layer with attention in Keras for translating dates.

This repository comes with a tutorial found here: https://medium.com/datalogue/attention-in-keras-1892773a4f22

Setting up the repository

  1. Make sure you have Python 3.4+ installed.

  2. Clone this repository to your local system

git clone https://github.com/datalogue/keras-attention.git
  1. Install the requirements (You can skip this step if you have all the requirements already installed)

We recommend using GPU's otherwise training might be prohbitively slow:

pip install -r requirements-gpu.txt

If you do not have a GPU or want to prototype on your local machine:

pip install -r requirements.txt

Creating the dataset

cd into data and run

python generate.py

This will create 4 files:

  1. training.csv - data to train the model
  2. validation.csv - data to evaluate the model and compare performance
  3. human_vocab.json - vocabulary for the human dates
  4. machine_vocab.json - vocabulary for the machine dates

Running the model

We highly recommending having a machine with a GPU to run this software, otherwise training might be prohibitively slow. To see what arguments are accepted you can run python run.py -h from the main directory:

usage: run.py [-h] [-e |] [-g |] [-p |] [-t |] [-v |] [-b |]

optional arguments:
  -h, --help            show this help message and exit

named arguments:
  -e |, --epochs |      Number of Epochs to Run
  -g |, --gpu |         GPU to use
  -p |, --padding |     Amount of padding to use
  -t |, --training-data |
                        Location of training data
  -v |, --validation-data |
                        Location of validation data
  -b |, --batch-size |  Location of validation data

All parameters have default values, so if you want to just run it, you can type python run.py. You can always stop running the model early using Ctrl+C.

Visualizing Attention

You can use the script visualize.py to visualize the attention map. We have provided sample weights and vocabularies in data/ and weights/ so that this script can run automatically using just an example. Run with the -h argument to see what is accepted:

usage: visualize.py [-h] -e | [-w |] [-p |] [-hv |] [-mv |]

optional arguments:
  -h, --help            show this help message and exit

named arguments:
  -e |, --examples |    Example string/file to visualize attention map for If
                        file, it must end with '.txt'
  -w |, --weights |     Location of weights
  -p |, --padding |     Length of padding
  -hv |, --human-vocab |
                        Path to the human vocabulary
  -mv |, --machine-vocab |
                        Path to the machine vocabulary

The default padding parameters correspond between run.py and visualize.py and therefore, if you change this make sure to note it. You must supply the path to the weights you want to use and an example/file of examples. An example file is provided in examples.txt.

Example visualizations

Here are some example visuals you can obtain:

image

The model has learned that “Saturday” has no predictive value!

image

We can see the weirdly formatted date “January 2016 5” is incorrectly translated as 2016–01–02 where the “02” comes from the “20” in 2016

Help

Start an issue and we will do our best to help!

Acknowledgements

As with all open source code, we could not have built this without other code out there. Special thanks to:

  1. rasmusbergpalm/normalization - for some of the data generation code.
  2. joke2k/faker for their fake data generator.

References

Bahdanau, Dzmitry, Kyunghyun Cho, and Yoshua Bengio. "Neural machine translation by jointly learning to align and translate." arXiv preprint arXiv:1409.0473 (2014).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].