Attention mechanism for processing sequence data that considers the context for each timestamp
Project description
Attention mechanism for processing sequence data that considers the context for each timestamp.
Install
pip install keras-self-attention
Usage
import keras
from keras_self_attention import Attention
model = keras.models.Sequential()
model.add(keras.layers.Embedding(input_dim=10000,
output_dim=300,
mask_zero=True))
model.add(keras.layers.Bidirectional(keras.layers.LSTM(units=128,
return_sequences=True)))
model.add(Attention())
model.add(keras.layers.Dense(units=5))
model.compile(
optimizer='adam',
loss='categorical_crossentropy',
metrics=['categorical_accuracy'],
)
model.summary()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for keras-self-attention-0.0.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc1d48a791b2fa0edd15e8774df044601cb635226ff5b30845fd597db2fdcf4f |
|
MD5 | b1e572fdc146b93f025b50243caba91f |
|
BLAKE2b-256 | 4e95dd3303f7fb0e3c46f098f42d181e8b1b2d649d1c860219a2f1ff33f805f2 |