Simple CNN
A minimal convolutional neural network implemented in PyTorch.
Model Description
Simple CNN is an experimental convolutional neural network designed to explore image processing with convolutional layers.
The model accepts grayscale images represented as tensors with shape (batch_size, 1, height, width).
The current example resizes input images to 8×8 pixels.
Architecture
The model contains two convolutional layers:
Conv2d: extracts local image features while preserving spatial dimensions.Conv2dwith stride2: reduces the spatial dimensions by half.
For an input tensor of shape (1, 1, 8, 8), the outputs have these shapes:
conv:(1, 1, 8, 8)down:(1, 1, 4, 4)
Intended Use
This model is an educational experiment for exploring CNN architecture, tensor shapes, convolution operations, and model serialization.
Training
The current version has not been trained on a dataset. Its weights are randomly initialized.
The outputs should not be interpreted as meaningful predictions.
Limitations
- The model has not been trained.
- It does not provide a task-specific prediction.
- Its output depends on randomly initialized weights.
- The example uses grayscale images resized to
8×8pixels.
Frameworks
- PyTorch
- Hugging Face Hub
- Pillow
- Torchvision
Usage
The model architecture is defined in model.py. Load the saved configuration and weights using the corresponding implementation.
import torch
from transformers import PreTrainedConfig
from model import CNN
device = torch.device(
"cuda" if torch.cuda.is_available() else "cpu"
)
config = PreTrainedConfig.from_pretrained(
"Erik606/test-to-hf"
)
# Use your CNNConfig class instead of PreTrainedConfig
# if model.py defines that custom configuration.
model = CNN(config).to(device)
state_dict = torch.hub.load_state_dict_from_url(
"https://huggingface.co/Erik606/test-to-hf/resolve/main/model.pt",
map_location=device,
)
model.load_state_dict(state_dict)
model.eval()
License
MIT
- Downloads last month
- -