v2.4
A Python library to easily build, train, and test your CNN AI models.

Build CNNs
From the Ground Up

A lightweight Python library dedicated to building, training, and testing Convolutional Neural Network (CNN) models with simplicity and clarity. It focuses exclusively on CNN workflows, Designed for developers who want full control and transparency over CNN architecture and training.

terminal Quick Install
pip install git+https://github.com/77AXEL/PyCNN.git
psychology

From Scratch

No deep learning frameworks

bolt

CUDA Ready

GPU acceleration support

school

Educational

Learn by implementation

hub

HuggingFace

Dataset integration

Installation

Get PyCNN up and running in minutes

check_circle

Prerequisites

  • Python 3.7+ required
  • GCC Compiler for Cython compilation
  • NumPy, PIL, SciPy auto-installed
  • CuPy optional for GPU support
download

Quick Install

Standard Installation

pip install git+https://github.com/77AXEL/PyCNN.git

With CUDA Support

pip install cupy-cuda118

Quick Start

Train your first CNN model in just a few lines of code. PyCNN handles all the complexity while maintaining transparency in how everything works under the hood.

  • check_circle Load datasets from HuggingFace or local folders
  • check_circle Configure custom layer architectures dynamically
  • check_circle Toggle between CPU and GPU with one line
  • check_circle Export trained models to PyTorch format
train_model.py
from pycnn.pycnn import PyCNN

# Initialize model
pycnn = PyCNN()
pycnn.cuda(True)  # Enable GPU

# Configure architecture
pycnn.init(
    batch_size=32,
    layers=[256, 128, 64],
    learning_rate=0.0001,
    epochs=100
)

# Use Adam optimizer
pycnn.adam()

# Load CIFAR-10 dataset
pycnn.dataset.hf(
    "cifar10",
    max_image=1000,
    cached=True
)

# Train with visualization
pycnn.train_model(
    visualize=True,
    early_stop=10
)

# Save the trained model
pycnn.save_model("model.bin")

Powerful Features

Everything you need to build, train, and deploy CNNs

code_blocks

Pure Implementation

Built entirely from scratch using NumPy, PIL, and SciPy. No TensorFlow or PyTorch dependencies for core functionality.

flash_on

CUDA Acceleration

Optional GPU support via CuPy for significantly faster training and inference on compatible hardware.

tune

Adam Optimizer

Advanced optimization with Adam algorithm for improved convergence and training stability.

layers

Custom Architectures

Define custom layer configurations dynamically. Experiment with different architectures easily.

database

Dataset Integration

Seamlessly load datasets from HuggingFace hub or local folders with automatic preprocessing.

show_chart

Training Visualization

Real-time plotting of accuracy and loss curves with Matplotlib during training sessions.

save

Model Persistence

Save and load trained models easily. Continue training or deploy for inference anytime.

sync_alt

PyTorch Export

Export your PyCNN models to PyTorch format for production deployment and framework integration.

photo_size_select_large

Image Augmentation

Built-in support for dataset augmentation techniques to improve model generalization.

How It Works

Understanding the complete pipeline from data to predictions

1

Data Preprocessing

Images are loaded, resized, normalized, and processed through custom convolution filters with ReLU activation and max-pooling operations.

2

Feature Extraction

Flattened feature maps from convolutional layers are passed through fully connected dense layers for high-level feature learning.

3

Backpropagation

Gradients computed via cross-entropy loss flow backward through the network, updating weights using Adam or SGD optimizer.

4

Classification

Dense layer outputs are processed with softmax activation for multi-class probability distribution and final predictions.

Perfect For

Who benefits from PyCNN?

school

Students & Educators

Learn deep learning fundamentals by examining transparent, readable source code. Perfect for courses on neural networks and computer vision.

science

Researchers

Rapidly prototype CNN architectures and experiment with novel approaches without framework overhead. Full control over every component.

code

Developers

Build custom CNN solutions for specific problems. Export to PyTorch when ready for production deployment at scale.

Try PyCNN Live

Experience PyCNN in action with our interactive CIFAR-10 classification demo running on HuggingFace Spaces.

Launch Demo open_in_new
rocket_launch

Join the Community

PyCNN is open source and welcomes contributions. Whether you're fixing bugs, adding features, or improving documentation, your help makes PyCNN better for everyone.