Skip to main content

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

Global Context

import tensorflow as tf

layer = LambdaLayer(
    dim = 32,       # channels going in
    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)

Local Context

layer = LambdaLayer(
    dim = 32,
    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)

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

tf-lambda-0.1.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

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

tf_lambda-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file tf-lambda-0.1.0.tar.gz.

File metadata

  • Download URL: tf-lambda-0.1.0.tar.gz
  • Upload date:
  • Size: 2.9 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

Hashes for tf-lambda-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c6fa336cbdbce8c2fb44f6f4e60c4256bfe66ad4a4d732e7021719387dc53065
MD5 19379e8216570e1288e33ff8b8e89dbe
BLAKE2b-256 26467ae8610202ecd641298d14d4390ec2e77232fef6c854a2f3d3947748b17a

See more details on using hashes here.

File details

Details for the file tf_lambda-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tf_lambda-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 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

Hashes for tf_lambda-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09fa158b6c344a0abc45b958f6108ec9821db9f0e722553b33ef90e5679048f3
MD5 0ca4b5b16faaddb6ff820f4cbcc6c4d9
BLAKE2b-256 c79bd22120bbfb5370cb6a46ead7656d179fadf202a5f95aee209bf95c717b43

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