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.1.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.1.tar.gz.

File metadata

File hashes

Hashes for convolutional_autoencoder_pytorch-1.0.1.tar.gz
Algorithm Hash digest
SHA256 978398cf52e53a508f8e637fc004dc12087969c9fa2198ad8201ae5aa68ae9f3
MD5 49f3a74c7c7b4d24d63042a0e88b84a7
BLAKE2b-256 b194bffde167f9fc0b48ddb8d673350d17c7a9e17cd9f24c6769fc6a08bba9f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for convolutional_autoencoder_pytorch-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 05684a945a497cf127767c0187eb834f76ad50fbb6f6ff3d437e8f0c7ef9b6a7
MD5 10b71eeebd85ebbec237a2830aad9297
BLAKE2b-256 4983dbc006b40b07e5f4b9de0c70bfbb29c17d496f4e98727f11917216ffa34f

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