pyautoencoder 1.0.7__tar.gz → 1.0.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. pyautoencoder-1.0.8/.github/workflows/ci.yml +36 -0
  2. pyautoencoder-1.0.8/.github/workflows/publish.yml +33 -0
  3. pyautoencoder-1.0.8/.gitignore +177 -0
  4. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/LICENSE +21 -21
  5. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/PKG-INFO +156 -165
  6. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/README.md +134 -134
  7. pyautoencoder-1.0.8/assets/logo_nobackground.png +0 -0
  8. pyautoencoder-1.0.8/examples/mnist_ae.py +123 -0
  9. pyautoencoder-1.0.8/examples/mnist_vae_kingma2013.py +151 -0
  10. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/pyautoencoder/__init__.py +5 -5
  11. pyautoencoder-1.0.8/pyautoencoder/_base/base.py +163 -0
  12. pyautoencoder-1.0.8/pyautoencoder/_version.py +34 -0
  13. pyautoencoder-1.0.8/pyautoencoder/experimental/__init__.py +0 -0
  14. pyautoencoder-1.0.8/pyautoencoder/experimental/benchmark_datasets/__init__.py +0 -0
  15. pyautoencoder-1.0.8/pyautoencoder/experimental/benchmark_datasets/disentanglement.py +84 -0
  16. pyautoencoder-1.0.8/pyautoencoder/experimental/hypernetworks.py +261 -0
  17. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/pyautoencoder/loss/__init__.py +12 -12
  18. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/pyautoencoder/loss/base.py +67 -67
  19. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/pyautoencoder/loss/vae.py +94 -88
  20. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/pyautoencoder/loss/wrapper.py +217 -213
  21. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/pyautoencoder/vanilla/__init__.py +2 -2
  22. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/pyautoencoder/vanilla/autoencoder.py +90 -90
  23. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/pyautoencoder/variational/__init__.py +2 -2
  24. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/pyautoencoder/variational/stochastic_layers.py +71 -69
  25. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/pyautoencoder/variational/vae.py +141 -141
  26. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/pyautoencoder.egg-info/PKG-INFO +156 -165
  27. pyautoencoder-1.0.8/pyautoencoder.egg-info/SOURCES.txt +38 -0
  28. pyautoencoder-1.0.8/pyautoencoder.egg-info/requires.txt +1 -0
  29. pyautoencoder-1.0.8/pyproject.toml +51 -0
  30. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/setup.cfg +4 -4
  31. pyautoencoder-1.0.8/test/_base/test_base.py +607 -0
  32. pyautoencoder-1.0.8/test/loss/test_base_loss.py +170 -0
  33. pyautoencoder-1.0.8/test/loss/test_vae_loss.py +272 -0
  34. pyautoencoder-1.0.8/test/loss/test_wrapper.py +342 -0
  35. pyautoencoder-1.0.8/test/vanilla/test_autoencoder.py +210 -0
  36. pyautoencoder-1.0.8/test/variational/test_stochastic_layers.py +203 -0
  37. pyautoencoder-1.0.8/test/variational/test_vae.py +324 -0
  38. pyautoencoder-1.0.7/pyautoencoder/base/base.py +0 -152
  39. pyautoencoder-1.0.7/pyautoencoder.egg-info/SOURCES.txt +0 -20
  40. pyautoencoder-1.0.7/pyautoencoder.egg-info/requires.txt +0 -1
  41. pyautoencoder-1.0.7/setup.py +0 -31
  42. {pyautoencoder-1.0.7/pyautoencoder/base → pyautoencoder-1.0.8/pyautoencoder/_base}/__init__.py +0 -0
  43. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/pyautoencoder.egg-info/dependency_links.txt +0 -0
  44. {pyautoencoder-1.0.7 → pyautoencoder-1.0.8}/pyautoencoder.egg-info/top_level.txt +0 -0
@@ -0,0 +1,36 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+
8
+ jobs:
9
+ tests:
10
+ runs-on: ubuntu-latest
11
+
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
16
+
17
+ steps:
18
+ - name: Checkout repository
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Set up Python ${{ matrix.python-version }}
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+
26
+ - name: Install dependencies
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ # install your package and test deps
30
+ pip install .
31
+ pip install pytest
32
+ # if you have more dev deps, add them here
33
+
34
+ - name: Run tests
35
+ run: |
36
+ pytest
@@ -0,0 +1,33 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ id-token: write
13
+ contents: read
14
+
15
+ steps:
16
+ - name: Checkout repository
17
+ uses: actions/checkout@v4
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: "3.11"
23
+
24
+ - name: Install build tooling
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install build
28
+
29
+ - name: Build package
30
+ run: python -m build
31
+
32
+ - name: Publish to PyPI via OIDC
33
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,177 @@
1
+ .vscode
2
+ data
3
+
4
+ # Byte-compiled / optimized / DLL files
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+
9
+ # C extensions
10
+ *.so
11
+
12
+ # Distribution / packaging
13
+ .Python
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ wheels/
26
+ share/python-wheels/
27
+ *.egg-info/
28
+ .installed.cfg
29
+ *.egg
30
+ MANIFEST
31
+
32
+ # PyInstaller
33
+ # Usually these files are written by a python script from a template
34
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
35
+ *.manifest
36
+ *.spec
37
+
38
+ # Installer logs
39
+ pip-log.txt
40
+ pip-delete-this-directory.txt
41
+
42
+ # Unit test / coverage reports
43
+ htmlcov/
44
+ .tox/
45
+ .nox/
46
+ .coverage
47
+ .coverage.*
48
+ .cache
49
+ nosetests.xml
50
+ coverage.xml
51
+ *.cover
52
+ *.py,cover
53
+ .hypothesis/
54
+ .pytest_cache/
55
+ cover/
56
+
57
+ # Translations
58
+ *.mo
59
+ *.pot
60
+
61
+ # Django stuff:
62
+ *.log
63
+ local_settings.py
64
+ db.sqlite3
65
+ db.sqlite3-journal
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # PyBuilder
78
+ .pybuilder/
79
+ target/
80
+
81
+ # Jupyter Notebook
82
+ .ipynb_checkpoints
83
+
84
+ # IPython
85
+ profile_default/
86
+ ipython_config.py
87
+
88
+ # pyenv
89
+ # For a library or package, you might want to ignore these files since the code is
90
+ # intended to run in multiple environments; otherwise, check them in:
91
+ # .python-version
92
+
93
+ # pipenv
94
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
96
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
97
+ # install all needed dependencies.
98
+ #Pipfile.lock
99
+
100
+ # UV
101
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
102
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
103
+ # commonly ignored for libraries.
104
+ #uv.lock
105
+
106
+ # poetry
107
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
108
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
109
+ # commonly ignored for libraries.
110
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
111
+ #poetry.lock
112
+
113
+ # pdm
114
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
115
+ #pdm.lock
116
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
117
+ # in version control.
118
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
119
+ .pdm.toml
120
+ .pdm-python
121
+ .pdm-build/
122
+
123
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
124
+ __pypackages__/
125
+
126
+ # Celery stuff
127
+ celerybeat-schedule
128
+ celerybeat.pid
129
+
130
+ # SageMath parsed files
131
+ *.sage.py
132
+
133
+ # Environments
134
+ .env
135
+ .venv
136
+ env/
137
+ venv/
138
+ ENV/
139
+ env.bak/
140
+ venv.bak/
141
+
142
+ # Spyder project settings
143
+ .spyderproject
144
+ .spyproject
145
+
146
+ # Rope project settings
147
+ .ropeproject
148
+
149
+ # mkdocs documentation
150
+ /site
151
+
152
+ # mypy
153
+ .mypy_cache/
154
+ .dmypy.json
155
+ dmypy.json
156
+
157
+ # Pyre type checker
158
+ .pyre/
159
+
160
+ # pytype static type analyzer
161
+ .pytype/
162
+
163
+ # Cython debug symbols
164
+ cython_debug/
165
+
166
+ # PyCharm
167
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
168
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
169
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
170
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
171
+ #.idea/
172
+
173
+ # Ruff stuff:
174
+ .ruff_cache/
175
+
176
+ # PyPI configuration file
177
+ .pypirc
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Andrea Pollastro
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Andrea Pollastro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,165 +1,156 @@
1
- Metadata-Version: 2.4
2
- Name: pyautoencoder
3
- Version: 1.0.7
4
- Summary: A Python package offering implementations of state-of-the-art autoencoder architectures in PyTorch.
5
- Home-page: https://github.com/andrea-pollastro/pyautoencoder
6
- Author: Andrea Pollastro
7
- License: MIT
8
- Keywords: autoencoder,pytorch,deep learning,machine learning,representation learning,dimensionality reduction,generative models
9
- Classifier: Operating System :: OS Independent
10
- Classifier: Intended Audience :: Science/Research
11
- Classifier: Intended Audience :: Developers
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Programming Language :: Python
14
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
15
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
- Requires-Python: >=3.7
17
- Description-Content-Type: text/markdown
18
- License-File: LICENSE
19
- Requires-Dist: torch>=2.0.0
20
- Dynamic: author
21
- Dynamic: classifier
22
- Dynamic: description
23
- Dynamic: description-content-type
24
- Dynamic: home-page
25
- Dynamic: keywords
26
- Dynamic: license
27
- Dynamic: license-file
28
- Dynamic: requires-dist
29
- Dynamic: requires-python
30
- Dynamic: summary
31
-
32
- # PyAutoencoder
33
-
34
- A clean, modular PyTorch library for building and training autoencoders.
35
-
36
- <!-- <p align="center">
37
- <img src="assets/logo_nobackground.png" alt="pyautoencoder logo" width="220"/>
38
- </p> -->
39
-
40
- ![logo](https://raw.githubusercontent.com/andrea-pollastro/pyautoencoder/main/assets/logo_nobackground.png)
41
-
42
- <p align="center">
43
- <a href="https://pypi.org/project/pyautoencoder/"><img alt="PyPI" src="https://img.shields.io/pypi/v/pyautoencoder.svg"></a>
44
- <a href="https://github.com/andrea-pollastro/pyautoencoder/blob/main/LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-blue.svg"></a>
45
- <a href="https://github.com/andrea-pollastro/pyautoencoder/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/andrea-pollastro/pyautoencoder?style=social"></a>
46
- </p>
47
-
48
- ---
49
-
50
- ## Highlights
51
-
52
- PyAutoencoder is designed to offer **simple and easy access to autoencoder frameworks**. Here's what it offers:
53
-
54
- - **Minimal, composable API**
55
- 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.
56
-
57
- - **Ready‑to‑use autoencoders**
58
- 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.
59
-
60
- - **PyTorch compatibility**
61
- The library is fully compatible with the PyTorch ecosystem, so models integrate naturally with modules, tensors, optimizers, and schedulers.
62
-
63
- - **Lightweight, research‑oriented**
64
- 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.
65
-
66
- > **Status**: The project is in an early but usable stage. Contributions, issues, and feedback are highly encouraged!
67
-
68
- **Currently implemented**:
69
- - Autoencoder (AE)
70
- - Variational Autoencoder (VAE)
71
-
72
- ---
73
-
74
- ## Installation
75
-
76
- ```bash
77
- pip install pyautoencoder
78
- ```
79
-
80
- Or install from source for development:
81
-
82
- ```bash
83
- git clone https://github.com/andrea-pollastro/pyautoencoder.git
84
- cd pyautoencoder
85
- pip install -e .
86
- ```
87
-
88
- ## Quick start
89
-
90
- ```python
91
- import torch
92
- import torch.nn as nn
93
- from pyautoencoder.variational import VAE
94
- from pyautoencoder.loss import VAELoss
95
-
96
- # Define encoder/decoder
97
- encoder = nn.Sequential(
98
- nn.Linear(784, 512),
99
- nn.ReLU(),
100
- nn.Linear(512, 256)
101
- )
102
-
103
- decoder = nn.Sequential(
104
- nn.Linear(256, 512),
105
- nn.ReLU(),
106
- nn.Linear(512, 784)
107
- )
108
-
109
- # Model
110
- vae = VAE(encoder=encoder, decoder=decoder, latent_dim=32)
111
-
112
- # Loss
113
- criterion = VAELoss(beta=1.0, likelihood="gaussian")
114
- optimizer = torch.optim.Adam(vae.parameters())
115
- for x in dataloader:
116
- optimizer.zero_grad()
117
- out = vae(x)
118
- losses = criterion(out, x)
119
- losses.total.backward() # negative ELBO
120
- optimizer.step()
121
-
122
- # optional: log components
123
- log_likelihood = losses.components["log_likelihood"]
124
- kl_divergence = losses.components["kl_divergence"]
125
- ```
126
-
127
- ## Built‑in models
128
-
129
- - **`AE`** — standard Autoencoder
130
- ```python
131
- from pyautoencoder.vanilla import AE
132
- from pyautoencoder.loss import AELoss
133
- ae = AE(encoder=encoder, decoder=decoder)
134
- criterion = AELoss(likelihood="gaussian") # or bernoulli
135
- ```
136
-
137
- - **`VAE`** — Variational Autoencoder
138
- ```python
139
- from pyautoencoder.variational import VAE, VAELoss
140
- from pyautoencoder.loss import VAELoss
141
- vae = VAE(encoder=encoder, decoder=decoder, latent_dim=32)
142
- criterion = VAELoss(beta=1.0, likelihood="gaussian") # or bernoulli
143
- ```
144
-
145
- ## Examples
146
-
147
- See the [`examples/`](examples/) folder for runnable scripts showing example of usage.
148
-
149
- ## License
150
-
151
- This project is released under the **MIT License**. See [LICENSE](LICENSE).
152
-
153
- ## Citation
154
-
155
- If you use this package in academic work, please cite:
156
-
157
- ```bibtex
158
- @misc{pollastro2025pyautoencoder,
159
- author = {Andrea Pollastro},
160
- title = {pyautoencoder},
161
- year = {2025},
162
- howpublished = {GitHub repository},
163
- url = {https://github.com/andrea-pollastro/pyautoencoder}
164
- }
165
- ```
1
+ Metadata-Version: 2.4
2
+ Name: pyautoencoder
3
+ Version: 1.0.8
4
+ Summary: A Python package offering implementations of state-of-the-art autoencoder architectures in PyTorch.
5
+ Author: Andrea Pollastro
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/andrea-pollastro/pyautoencoder
8
+ Project-URL: Repository, https://github.com/andrea-pollastro/pyautoencoder
9
+ Keywords: autoencoder,pytorch,deep learning,machine learning,representation learning,dimensionality reduction,generative models
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: torch>=2.1.0
21
+ Dynamic: license-file
22
+
23
+ # PyAutoencoder
24
+
25
+ A clean, modular PyTorch library for building and training autoencoders.
26
+
27
+ <!-- <p align="center">
28
+ <img src="assets/logo_nobackground.png" alt="pyautoencoder logo" width="220"/>
29
+ </p> -->
30
+
31
+ ![logo](https://raw.githubusercontent.com/andrea-pollastro/pyautoencoder/main/assets/logo_nobackground.png)
32
+
33
+ <p align="center">
34
+ <a href="https://pypi.org/project/pyautoencoder/"><img alt="PyPI" src="https://img.shields.io/pypi/v/pyautoencoder.svg"></a>
35
+ <a href="https://github.com/andrea-pollastro/pyautoencoder/blob/main/LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-blue.svg"></a>
36
+ <a href="https://github.com/andrea-pollastro/pyautoencoder/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/andrea-pollastro/pyautoencoder?style=social"></a>
37
+ </p>
38
+
39
+ ---
40
+
41
+ ## Highlights
42
+
43
+ PyAutoencoder is designed to offer **simple and easy access to autoencoder frameworks**. Here's what it offers:
44
+
45
+ - **Minimal, composable API**
46
+ 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.
47
+
48
+ - **Ready‑to‑use autoencoders**
49
+ 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.
50
+
51
+ - **PyTorch compatibility**
52
+ The library is fully compatible with the PyTorch ecosystem, so models integrate naturally with modules, tensors, optimizers, and schedulers.
53
+
54
+ - **Lightweight, research‑oriented**
55
+ 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.
56
+
57
+ > **Status**: The project is in an early but usable stage. Contributions, issues, and feedback are highly encouraged!
58
+
59
+ **Currently implemented**:
60
+ - Autoencoder (AE)
61
+ - Variational Autoencoder (VAE)
62
+
63
+ ---
64
+
65
+ ## Installation
66
+
67
+ ```bash
68
+ pip install pyautoencoder
69
+ ```
70
+
71
+ Or install from source for development:
72
+
73
+ ```bash
74
+ git clone https://github.com/andrea-pollastro/pyautoencoder.git
75
+ cd pyautoencoder
76
+ pip install -e .
77
+ ```
78
+
79
+ ## Quick start
80
+
81
+ ```python
82
+ import torch
83
+ import torch.nn as nn
84
+ from pyautoencoder.variational import VAE
85
+ from pyautoencoder.loss import VAELoss
86
+
87
+ # Define encoder/decoder
88
+ encoder = nn.Sequential(
89
+ nn.Linear(784, 512),
90
+ nn.ReLU(),
91
+ nn.Linear(512, 256)
92
+ )
93
+
94
+ decoder = nn.Sequential(
95
+ nn.Linear(256, 512),
96
+ nn.ReLU(),
97
+ nn.Linear(512, 784)
98
+ )
99
+
100
+ # Model
101
+ vae = VAE(encoder=encoder, decoder=decoder, latent_dim=32)
102
+
103
+ # Loss
104
+ criterion = VAELoss(beta=1.0, likelihood="gaussian")
105
+ optimizer = torch.optim.Adam(vae.parameters())
106
+ for x in dataloader:
107
+ optimizer.zero_grad()
108
+ out = vae(x)
109
+ losses = criterion(out, x)
110
+ losses.total.backward() # negative ELBO
111
+ optimizer.step()
112
+
113
+ # optional: log components
114
+ log_likelihood = losses.components["log_likelihood"]
115
+ kl_divergence = losses.components["kl_divergence"]
116
+ ```
117
+
118
+ ## Built‑in models
119
+
120
+ - **`AE`** — standard Autoencoder
121
+ ```python
122
+ from pyautoencoder.vanilla import AE
123
+ from pyautoencoder.loss import AELoss
124
+ ae = AE(encoder=encoder, decoder=decoder)
125
+ criterion = AELoss(likelihood="gaussian") # or bernoulli
126
+ ```
127
+
128
+ - **`VAE`** — Variational Autoencoder
129
+ ```python
130
+ from pyautoencoder.variational import VAE, VAELoss
131
+ from pyautoencoder.loss import VAELoss
132
+ vae = VAE(encoder=encoder, decoder=decoder, latent_dim=32)
133
+ criterion = VAELoss(beta=1.0, likelihood="gaussian") # or bernoulli
134
+ ```
135
+
136
+ ## Examples
137
+
138
+ See the [`examples/`](examples/) folder for runnable scripts showing example of usage.
139
+
140
+ ## License
141
+
142
+ This project is released under the **MIT License**. See [LICENSE](LICENSE).
143
+
144
+ ## Citation
145
+
146
+ If you use this package in academic work, please cite:
147
+
148
+ ```bibtex
149
+ @misc{pollastro2025pyautoencoder,
150
+ author = {Andrea Pollastro},
151
+ title = {pyautoencoder},
152
+ year = {2025},
153
+ howpublished = {GitHub repository},
154
+ url = {https://github.com/andrea-pollastro/pyautoencoder}
155
+ }
156
+ ```