Kattention
This package implements different Attention mechanisms as Keras layers.
Setup
pip install kattention
Usage
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Flatten, Dense, Softmax
from kattention.layers import Transformer
SEQUENCE_LENGTH = 4
EMBEDDING_SIZE = 300
CLASSES_TO_PREDICT = 5
ATT_HEADS = 2
model = Sequential()
model.add(Transformer(attention_heads=ATT_HEADS, input_shape=(SEQUENCE_LENGTH, EMBEDDING_SIZE)))
model.add(Transformer(attention_heads=ATT_HEADS))
model.add(Flatten())
model.add(Dense(CLASSES_TO_PREDICT))
model.add(Softmax())
print(model.summary())
Metadata
Release files for kattention 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| kattention-0.1.2.tar.gz | 2.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kattention-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.6 kB
Release files / kattention-0.1.2.tar.gz
| Download URL | kattention-0.1.2.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b0df6edb479d9b8dcadfb0812db20d51c2d92a74ce7044bc22ef7c974d46ee3
|
|
BLAKE2b-256 checksum How to use checksums |
235a117c5d49831f4ded115d2f8d00a6ca882e6576812a2b030b5a809f7e585c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8
|
Release files / kattention-0.1.2-py3-none-any.whl
| Download URL | kattention-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa9af9b3fee639e0e7127c03978bdd8bd085d34cf85c3d0cffade3a1fa0954ed
|
|
BLAKE2b-256 checksum How to use checksums |
e8586520e35792db0c808a40e56c90c48ef806d9078ef249001506f1f46200d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.8
|