language:
- en
tags:
- pytorch
- mnist
- neural-network
license: apache-2.0
datasets:
- mnist
Model Card for MyNeuralNet
Model Description
MyNeuralNet
is a simple, fully connected neural network designed for classifying the handwritten digits of the MNIST dataset. The model consists of three linear layers with ReLU activation functions, followed by a final layer with a softmax output to predict probabilities across the 10 possible digits (0-9).
How the Model Was Trained
The model was trained using the MNIST dataset, which consists of 60,000 training images and 10,000 test images. Each image is a 28x28 grayscale representation of a handwritten digit. Training was conducted over 20 epochs with a batch size of 32. The SGD optimizer was used with a learning rate of 0.01.
Training Script
The model training was carried out using a custom PyTorch script, similar to the following pseudocode:
for epoch in range(n_epochs):
for images, labels in dataloader:
# Forward pass
predictions = model(images)
loss = loss_function(predictions, labels)
# Backward pass and optimization
optimizer.zero_grad()
loss.backward()
optimizer.step()
Using the Model
Below is a simple example of how to load MyNeuralNet
and use it to predict MNIST images:
import torch
import torch.nn as nn
from torch import load
from huggingface_hub import hf_hub_download
class MyNeuralNet(nn.Module):
def __init__(self):
super(MyNeuralNet, self).__init__()
self.Matrix1 = nn.Linear(28*28, 100)
self.Matrix2 = nn.Linear(100, 50)
self.Matrix3 = nn.Linear(50, 10)
self.R = nn.ReLU()
def forward(self, x):
x = x.view(-1, 28*28)
x = self.R(self.Matrix1(x))
x = self.R(self.Matrix2(x))
x = self.Matrix3(x)
return x.squeeze()
model_state_dict = load(hf_hub_download(repo_id="Svenni551/May-stablelm-2-zephyr-1_6b", filename="model.pth"), map_location=torch.device('cpu'))
model = MyNeuralNet()
model.load_state_dict(model_state_dict)
model.eval()
# Use 'model' for predictions
Performance
Describe your model's performance on the test data or during validation. You might want to include metrics such as accuracy, precision, recall, and F1 score.
Limitations and Ethics
This model was solely trained on the MNIST dataset and is optimized only for recognizing handwritten digits. Its application in other contexts has not been tested and might lead to inaccurate results.
License
The MyNeuralNet model is made available under the Apache-2.0 license. For more details, please refer to the LICENSE file in the repository.