A TensorFlow 2 implementation of LambdaNetworks.
Project description
Lambda Networks
This is a TensorFlow 2 implementation of a Lambda Layer from: LambdaNetworks: Modeling Long-Range Interactions Without Attention. LambdaNetworks achieve SOTA on ImageNet. For now, this library provides a basic UNTESTED version of the Lambda Layer based off of this repository.
Usage
Lambda Layer
Global Context
import tensorflow as tf
from tf_lambda.layers.lambda_layer import LambdaLayer
layer = LambdaLayer(
dim_out = 32, # channels out
n = 64 * 64, # number of input pixels (64 x 64 image)
dim_k = 16, # key dimension
heads = 4, # number of heads, for multi-query
dim_u = 1 # 'intra-depth' dimension
)
x = tf.random.normal(shape=(1, 64, 64, 32))
layer(x)
Localized Context
layer = LambdaLayer(
dim_out = 32,
r = 23, # the receptive field for relative positional encoding (23 x 23)
dim_k = 16,
heads = 4,
dim_u = 4
)
x = tf.random.normal(shape=(1, 64, 64, 32))
layer(x)
Lambda Conv
Just a wrapper around the Lambda Layer. Builds it specifically for image data. The only thing you need to specify is the number of channels to output.
from tf_lambda.layers.lambda_conv import LambdaConv
layer = LambdaConv(32)
x = tf.random.normal(shape=(1, 64, 64, 32))
layer(x)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tf-lambda-0.4.0.tar.gz.
File metadata
- Download URL: tf-lambda-0.4.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4dd9eeaf074d676268d920f27176511026748ef9b6862ebbe2f54d63cbbfbdac
|
|
| MD5 |
a234092b12974b84b5a515fdbf4f3650
|
|
| BLAKE2b-256 |
0bb954b0c34c906eb891778ae9c8646381284459de8a9c44e9075a694c9dd799
|
File details
Details for the file tf_lambda-0.4.0-py3-none-any.whl.
File metadata
- Download URL: tf_lambda-0.4.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
799d09fbd9959f55a187374fcce5b5f8a2e2e3f3c94e2742d6c89cb48cc63ce3
|
|
| MD5 |
981e483f685699354fcedbd0146a91b0
|
|
| BLAKE2b-256 |
e12cad50721a62f27e2e5218b0c6e66bbc490e0558368deaa97dd10aea5be068
|