Skip to main content

Package implementing different attention mechanisms as tf.keras layers

Project description

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())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kattention-0.1.2.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kattention-0.1.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file kattention-0.1.2.tar.gz.

File metadata

  • Download URL: kattention-0.1.2.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for kattention-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8b0df6edb479d9b8dcadfb0812db20d51c2d92a74ce7044bc22ef7c974d46ee3
MD5 b52bd46bc0ca25b14917a4ccbd3438f0
BLAKE2b-256 235a117c5d49831f4ded115d2f8d00a6ca882e6576812a2b030b5a809f7e585c

See more details on using hashes here.

File details

Details for the file kattention-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: kattention-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for kattention-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fa9af9b3fee639e0e7127c03978bdd8bd085d34cf85c3d0cffade3a1fa0954ed
MD5 d37bb4b70f4a5e0259566dff0aec06b0
BLAKE2b-256 e8586520e35792db0c808a40e56c90c48ef806d9078ef249001506f1f46200d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page