Spline-Based Transformer
Implementation of the proposed Spline-Based Transformer (paper) from Disney Research
This is basically a transformer based autoencoder, but they cleverly use a set of latent tokens, where that set of tokens are the (high dimensional) control points for a spline.
Install
$ pip install spline-based-transformer
Usage
import torch
from spline_based_transformer import SplineBasedTransformer
model = SplineBasedTransformer(
dim = 512,
enc_depth = 6,
dec_depth = 6
)
data = torch.randn(1, 1024, 512)
loss = model(data, return_loss = True)
loss.backward()
# after much training
recon, control_points = model(data, return_latents = True)
assert data.shape == recon.shape
# mess with the control points, which should preserve continuity better
control_points += 1
controlled_recon = model.decode_from_latents(control_points, num_times = 1024)
assert controlled_recon.shape == data.shape
For an example of an image autoencoder
import torch
from spline_based_transformer import (
SplineBasedTransformer,
ImageAutoencoderWrapper
)
model = ImageAutoencoderWrapper(
image_size = 256,
patch_size = 32,
spline_transformer = SplineBasedTransformer(
dim = 512,
enc_depth = 6,
dec_depth = 6
)
)
images = torch.randn(2, 3, 256, 256)
loss = model(images, return_loss = True)
loss.backward()
# after much training
recon_images, control_points = model(images, return_latents = True)
assert images.shape == recon_images.shape
# changing the control points
control_points += 1
controlled_recon_images = model.decode_from_latents(control_points)
assert controlled_recon_images.shape == images.shape
Citations
@misc{Chandran2024,
author = {Prashanth Chandran, Agon Serifi, Markus Gross, Moritz Bächer},
url = {https://la.disneyresearch.com/publication/spline-based-transformers/}
}
Metadata
Release files for spline-based-transformer 0.0.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spline_based_transformer-0.0.14.tar.gz | 5.6 kB | Without provenance | Details for spline_based_transformer-0.0.14.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spline_based_transformer-0.0.14-py3-none-any.whl | Python 3 | none | any | Details for spline_based_transformer-0.0.14-py3-none-any.whl |
Total release size: 12.4 kB
Release files / spline_based_transformer-0.0.14.tar.gz
| Download URL | spline_based_transformer-0.0.14.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f023c41004b47c54639ca61288ba7fef979e19f9b076f06e618b22a6aaca86a2
|
|
BLAKE2b-256 checksum How to use checksums |
4376487dfa448da9ad2a987abf4e7823ca328cbca7cc2e20154029f6e5f48d9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Release files / spline_based_transformer-0.0.14-py3-none-any.whl
| Download URL | spline_based_transformer-0.0.14-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
be0f28c8254c07cd1b47d250b973c8b868c8584485eb8fbeebb9095f2182bf69
|
|
BLAKE2b-256 checksum How to use checksums |
ba1aedd7f34fa04836c0c27a8594092d26a7a0088f67add25a3e39d09d1aac07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Security for spline-based-transformer 0.0.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.