Attention Free Transformer - Pytorch
Project description
aft-pytorch
Unofficial PyTorch implementation of Attention Free Transformer's layers by Zhai, et al. [abs, pdf] from Apple Inc.
Installation
You can install aft-pytorch
via pip
:
pip install aft-pytorch
Usage
You can import the AFT-Full or AFT-Simple layer (as described in the paper) from the package like so:
AFTFull
from aft_pytorch import AFTFull
layer = AFTFull(
dim=512,
hidden_dim=64,
heads=8
)
# a batch of sequences with 10 timesteps of length 512 each
x = torch.rand(32, 10, 512)
y = layer(x) # [32, 10, 512]
AFTSimple
from aft_pytorch import AFTSimple
layer = AFTSimple(
dim=512,
hidden_dim=64,
heads=8
)
# a batch of sequences with 10 timesteps of length 512 each
x = torch.rand(32, 10, 512)
y = layer(x) # [32, 10, 512]
This layer wrapper is a 'plug-and-play' with your existing networks / Transformers. You can swap out the Self-Attention layer with the available layers in this package with minimal changes.
TODO
- Add full AFT architecture
- Add variants like,
AFTConv
,AFTLocal
Contributing
If you like this repo, please leave a star! If there are any amends or suggestions, feel free to raise a PR/issue.
Credits
@misc{
zhai2021an,
title={An Attention Free Transformer},
author={Shuangfei Zhai and Walter Talbott and Nitish Srivastava and Chen Huang and Hanlin Goh and Joshua M. Susskind},
year={2021},
url={https://openreview.net/forum?id=pW--cu2FCHY}
}
License
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
aft_pytorch-0.1.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for aft_pytorch-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3a0aa3c39c8dd1d2bda8bc0ee7d18385075e37cc575e2677830d4f2c23cf4fc |
|
MD5 | 67a9cce84a387c791b50f1bdeaa96f96 |
|
BLAKE2b-256 | 9ac8b1b42d37129a0a37ea86f78cffbe924a53bf57b77df700607a7c4a743511 |