A Python package offering implementations of state-of-the-art autoencoder architectures in PyTorch.
Project description
PyAutoencoder
A clean, modular PyTorch-based library for building and training autoencoders.
Highlights
PyAutoencoder is designed to offer simple and easy access to autoencoder frameworks. Here's what it offers:
-
Minimal, composable API
You don't have to inherit from complicated base classes or learn a new training loop. Simply provide your own PyTorch nn.Module encoder and decoder, and plug them into the ready‑to‑use autoencoder wrappers. This makes it easy to experiment with different architectures (e.g. MLPs, CNNs) while reusing the same training pipeline. -
Ready‑to‑use autoencoders The library ships with working implementations of autoencoders, each paired with their respective loss functions. You can start training in a few lines, without re‑implementing reconstruction likelihoods, KL divergence, or other boilerplate.
-
PyTorch compatibility
The library is fully compatible with the PyTorch ecosystem, so models integrate naturally with modules, tensors, optimizers, and schedulers. -
Lightweight, research‑oriented
The library is intentionally minimal: no training loop frameworks, no heavy abstractions. This makes it well suited for research prototypes where you want control and transparency.
Status: The project is in an early but usable stage. Contributions, issues, and feedback are highly encouraged!
Currently implemented:
- Autoencoder (AE)
- Variational Autoencoder (VAE)
Documentation
Full documentation (installation, tutorials, API reference, and examples) is available at:
👉 https://pyautoencoder.readthedocs.io/en/latest/
Installation
pip install pyautoencoder
Or install from source for development:
git clone https://github.com/andrea-pollastro/pyautoencoder.git
cd pyautoencoder
pip install -e .
Quick start
import torch
import torch.nn as nn
from pyautoencoder.variational import VAE
# Define encoder/decoder
latent_dim = 32
encoder = nn.Sequential(
nn.Linear(784, 512),
nn.ReLU(),
)
decoder = nn.Sequential(
nn.Linear(latent_dim, 512),
nn.ReLU(),
nn.Linear(512, 784)
)
# Model
vae = VAE(encoder=encoder, decoder=decoder, latent_dim=latent_dim)
optimizer = torch.optim.Adam(vae.parameters())
for x in dataloader:
optimizer.zero_grad()
out = vae(x)
loss_results = vae.compute_loss(out, x, beta=1, likelihood='bernoulli')
loss_results.objective.backward() # negative ELBO
optimizer.step()
# optional: log components
log_likelihood = loss_results.components["log_likelihood"]
kl_divergence = loss_results.components["kl_divergence"]
Examples
The examples/ directory contains runnable scripts, including:
mnist_ae.py– standard Autoencoder on MNISTmnist_vae_kingma2013.py– reproduction of the MNIST VAE experiment from Kingma & Welling (2013), Fig. 2
These examples are also documented and explained in the online documentation.
License
This project is released under the MIT License. See LICENSE.
Citation
If you use this package in academic work, please cite:
@article{pollastro2025sincvae,
title={SincVAE: A new semi-supervised approach to improve anomaly detection on EEG data using SincNet and variational autoencoder},
author={Pollastro, Andrea and Isgr{\`o}, Francesco and Prevete, Roberto},
journal={Computer Methods and Programs in Biomedicine Update},
pages={100213},
year={2025},
publisher={Elsevier}
}
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 pyautoencoder-1.1.0.tar.gz.
File metadata
- Download URL: pyautoencoder-1.1.0.tar.gz
- Upload date:
- Size: 418.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd50b83700a6a4f6ccdafd5ca51291e56aa1d402389bd594ff241fb8907e8b49
|
|
| MD5 |
a16fc92c10e849309184eee72dbc6783
|
|
| BLAKE2b-256 |
9231f710415ba7d3d40cf26c0f8767c7905a1e23c838d58624fe41f903798680
|
Provenance
The following attestation bundles were made for pyautoencoder-1.1.0.tar.gz:
Publisher:
publish.yml on andrea-pollastro/pyautoencoder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyautoencoder-1.1.0.tar.gz -
Subject digest:
fd50b83700a6a4f6ccdafd5ca51291e56aa1d402389bd594ff241fb8907e8b49 - Sigstore transparency entry: 774612073
- Sigstore integration time:
-
Permalink:
andrea-pollastro/pyautoencoder@2fdc3f00ddc74ab7982dd7a2d8551fccbdab9362 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/andrea-pollastro
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2fdc3f00ddc74ab7982dd7a2d8551fccbdab9362 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyautoencoder-1.1.0-py3-none-any.whl.
File metadata
- Download URL: pyautoencoder-1.1.0-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b195569536f61f10e2cc8edff853e1e2986164235abccc12959d439175890fd
|
|
| MD5 |
dd3cee968eb25a17ed3d5e73126c82d3
|
|
| BLAKE2b-256 |
830a077c366d10a34354b6dfd8c35e08388f9d95bfd22fa8c911cd2905b2bd86
|
Provenance
The following attestation bundles were made for pyautoencoder-1.1.0-py3-none-any.whl:
Publisher:
publish.yml on andrea-pollastro/pyautoencoder
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyautoencoder-1.1.0-py3-none-any.whl -
Subject digest:
0b195569536f61f10e2cc8edff853e1e2986164235abccc12959d439175890fd - Sigstore transparency entry: 774612075
- Sigstore integration time:
-
Permalink:
andrea-pollastro/pyautoencoder@2fdc3f00ddc74ab7982dd7a2d8551fccbdab9362 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/andrea-pollastro
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2fdc3f00ddc74ab7982dd7a2d8551fccbdab9362 -
Trigger Event:
push
-
Statement type: