Skip to main content

A package to simplify the implementing an autoencoder model.

Project description

convolutional-autoencoder-pytorch

A minimal, customizable PyTorch package for building and training convolutional autoencoders based on a simplified U-Net architecture (without skip connections). Ideal for representation learning, image compression, and reconstruction tasks.

🔧 Features

  • 📦 Modular architecture (Encoder, Decoder, AutoEncoder)
  • 🔁 Symmetric U-Net-like design without skip connections
  • ⚡ Tanh output activation for stable image reconstruction
  • 🧠 Residual blocks with RMS normalization and SiLU activation
  • 📱 Designed for image inputs (3×H×W) with configurable channels and latent dim
  • 🧪 Works with batched input tensors (e.g., torch.Tensor[B, C, H, W])

📦 Installation

You can access the PyPI page or install the package directly.

pip install convolutional-autoencoder-pytorch

🧩 Package Structure

convolutional-autoencoder-pytorch/
├── convolutional_autoencoder_pytorch/
│   ├── __init__.py
│   └── module.py          # All architecture classes and logic
├── pyproject.toml
├── LICENSE
└── README.md

🚀 Quick Start

1. Import the package and create the model

import torch
from convolutional_autoencoder_pytorch import AutoEncoder

model = AutoEncoder(
    dim=64,
    dim_mults=(1, 2, 4, 8),
    dim_latent=128,
    image_channels=3
)

2. Forward pass and reconstruction

images = torch.randn(8, 3, 128, 128)  # batch of images
reconstructed, latent = model(images)

# Or just get the reconstruction
recon = model.reconstruct(images)

3. Training step (sample loop)

import torch.nn.functional as F
optimizer = torch.optim.Adam(model.parameters(), lr=1e-4)

def train_step(images):
    model.train()
    optimizer.zero_grad()
    recon, _ = model(images)
    loss = F.mse_loss(recon, images)
    loss.backward()
    optimizer.step()
    return loss.item()

⚙️ Configuration Options

Parameter Description Default
dim Base channel size 64
dim_mults List of multipliers for down/up blocks (1, 2, 4, 8)
dim_latent Latent bottleneck dimension 64
image_channels Input/output image channels (e.g., 3) 3
dropout Dropout probability 0.0

🙋‍♂️ Author

Developed by Mehran Bazrafkan This project is an original implementation of a simplified autoencoder architecture. Some ideas and design inspirations were drawn from the open-source denoising-diffusion-pytorch project, but the code and architecture were written independently.

📢 Contributions & Feedback

Contributions, issues, and feedback are welcome via GitHub Issues.

📄 License

This project is licensed under the terms of the MIT LICENSE.

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

convolutional_autoencoder_pytorch-1.0.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file convolutional_autoencoder_pytorch-1.0.0.tar.gz.

File metadata

File hashes

Hashes for convolutional_autoencoder_pytorch-1.0.0.tar.gz
Algorithm Hash digest
SHA256 10d51296144f9e6461679e7dd57222016245d6fb6edd3db480d7eed760508956
MD5 f249d8eb9fc05d891a5f8f9d6dd94b30
BLAKE2b-256 63a240cb6af99e4247286336452a7aee1c1174474154d7647bcf5a0931ee222c

See more details on using hashes here.

File details

Details for the file convolutional_autoencoder_pytorch-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for convolutional_autoencoder_pytorch-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 21647c35880e571eb9750d3e4667f7db19f6fca190edebc76c3d3bedabc256d9
MD5 3a6387d0d1494f3a6ad641cef285b6ec
BLAKE2b-256 2886c1ec5206477105f1ae4cca7e527f4d7039c52b730ab1fa8ea29ae6bfbf21

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