Many-to-one attention mechanism for Keras. We demonstrate that using attention yields a higher accuracy on the IMDB dataset. We consider two LSTM networks: one with this attention layer and the other one with a fully connected layer. Both have the same number of parameters for a fair comparison (250K). The attention is expected to be the highest after the delimiters. An overview of the training is shown below, where the top represents the attention map and the bottom the ground truth. As the training progresses, the model learns the task and the attention map converges to the ground truth. We consider many 1D sequences of the same length. The task is to find the maximum of each sequence. We give the full sequence processed by the RNN layer to the attention layer. We expect the attention layer to focus on the maximum of each sequence.

Features

  • Find max of a sequence
  • Many-to-one attention mechanism for Keras
  • Attention mechanism Implementation
  • Browse examples

Project Samples

Project Activity

See All Activity >

Categories

Machine Learning

License

Apache License V2.0

Follow Keras Attention Mechanism

Keras Attention Mechanism Web Site

You Might Also Like
Employee monitoring software with screenshots Icon
Employee monitoring software with screenshots

Clear visibility and insights into how employees work. Even remotely.

Stay productive working at any distance from anywhere with Monitask.
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of Keras Attention Mechanism!

Additional Project Details

Programming Language

Python

Related Categories

Python Machine Learning Software

Registered

2022-08-05