MambaFormer
Implementation of MambaFormer in Pytorch ++ Zeta from the paper: "Can Mamba Learn How to Learn? A Comparative Study on In-Context Learning Tasks"
install
pip3 install mamba-former
usage
import torch
from mamba_former.main import MambaFormer
# Forward pass example
x = torch.randint(1, 1000, (1, 100)) # Token
# Tokens are integers representing input data
# Model
model = MambaFormer(
dim=512, # Dimension of the model
num_tokens=1000, # Number of unique tokens in the input data
depth=6, # Number of transformer layers
d_state=512, # Dimension of the transformer state
d_conv=128, # Dimension of the convolutional layer
heads=8, # Number of attention heads
dim_head=64, # Dimension of each attention head
return_tokens=True, # Whether to return the tokens in the output
)
# Forward pass
out = model(x) # Perform a forward pass through the model
# If training
# out = model(x, return_loss=True) # Perform a forward pass and calculate the loss
# Print the output
print(out) # Print the output tensor
print(out.shape) # Print the shape of the output tensor
License
MIT
Metadata
Release files for mamba-former 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mamba_former-0.0.3.tar.gz | 3.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mamba_former-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.7 kB
Release files / mamba_former-0.0.3.tar.gz
| Download URL | mamba_former-0.0.3.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b54d02e36848c3a9ade42c397d19f5b98e34df77664fb29213d77d775137bbd
|
|
BLAKE2b-256 checksum How to use checksums |
c00a5fcc07d8485c4f2c03af84a68c00b5c1c0f208cc713f0f19bef389f53538
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.0 Darwin/23.3.0
|
Release files / mamba_former-0.0.3-py3-none-any.whl
| Download URL | mamba_former-0.0.3-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b83622fd9dcbf6977a39d2056f1769e13a69c8f2569a05563774c37d00bc2a7d
|
|
BLAKE2b-256 checksum How to use checksums |
3713bfc8e5b02af8bd22677d085771d85e1773dca56ddce87e5879eb39127be4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.11.0 Darwin/23.3.0
|