mnist-cnn
pytorchv1.0.0A PyTorch convolutional neural network for handwritten digit recognition. Uses two Conv2d layers with max pooling, dropout regularization, and fully connected classification head. Trains on synthetically generated MNIST-like data with configurable epochs, learning rate, and batch size.
Computer Visionimage-classificationcnndeep-learningbeginner
Install
1openmodelstudio install mnist-cnn
SDK Usage
1import openmodelstudio as oms23model = oms.use_model("mnist-cnn")4handle = oms.register_model("my-mnist-cnn", model=model)5job = oms.start_training(handle.model_id, wait=True)
Source Preview(112 lines)
View full source1"""MNIST digit classification with a simple CNN."""23import torch4import torch.nn as nn5import torch.nn.functional as F67class MNISTNet(nn.Module):8 def __init__(self):9 super().__init__()10 self.conv1 = nn.Conv2d(1, 32, 3, padding=1)11 self.conv2 = nn.Conv2d(32, 64, 3, padding=1)12 self.pool = nn.MaxPool2d(2, 2)13 self.fc1 = nn.Linear(64 * 7 * 7, 128)14 self.fc2 = nn.Linear(128, 10)1516 def forward(self, x):17 x = self.pool(F.relu(self.conv1(x)))18 x = self.pool(F.relu(self.conv2(x)))19 x = x.view(-1, 64 * 7 * 7)20 return self.fc2(F.relu(self.fc1(x)))
Details
- Author
- openmodelstudio
- License
- MIT
- Source
- 112 lines
- Version
- 1.0.0
Dependencies
torch>=2.0torchvision>=0.15numpy>=1.24Hyperparameters
epochs5Number of training epochs
lr0.001Learning rate
batch_size64Training batch size
View on GitHub