Svenni21 commited on
Commit
3324684
2 Parent(s): 09e5980 0f4560c
Files changed (1) hide show
  1. README.md +83 -0
README.md ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - pytorch
6
+ - mnist
7
+ - neural-network
8
+ license: apache-2.0
9
+ datasets:
10
+ - mnist
11
+ ---
12
+
13
+ # Model Card for MyNeuralNet
14
+
15
+ ## Model Description
16
+
17
+ `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).
18
+
19
+ ## How the Model Was Trained
20
+
21
+ 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.
22
+
23
+ ### Training Script
24
+
25
+ The model training was carried out using a custom PyTorch script, similar to the following pseudocode:
26
+
27
+ ```python
28
+ for epoch in range(n_epochs):
29
+ for images, labels in dataloader:
30
+ # Forward pass
31
+ predictions = model(images)
32
+ loss = loss_function(predictions, labels)
33
+
34
+ # Backward pass and optimization
35
+ optimizer.zero_grad()
36
+ loss.backward()
37
+ optimizer.step()
38
+ ```
39
+
40
+ ## Using the Model
41
+
42
+ Below is a simple example of how to load `MyNeuralNet` and use it to predict MNIST images:
43
+
44
+ ```python
45
+ import torch
46
+ import torch.nn as nn
47
+ from torch import load
48
+ from huggingface_hub import hf_hub_download
49
+
50
+ class MyNeuralNet(nn.Module):
51
+ def __init__(self):
52
+ super(MyNeuralNet, self).__init__()
53
+ self.Matrix1 = nn.Linear(28*28, 100)
54
+ self.Matrix2 = nn.Linear(100, 50)
55
+ self.Matrix3 = nn.Linear(50, 10)
56
+ self.R = nn.ReLU()
57
+
58
+ def forward(self, x):
59
+ x = x.view(-1, 28*28)
60
+ x = self.R(self.Matrix1(x))
61
+ x = self.R(self.Matrix2(x))
62
+ x = self.Matrix3(x)
63
+ return x.squeeze()
64
+
65
+ model_state_dict = load(hf_hub_download(repo_id="Svenni551/may-mnist-digits", filename="model.pth"), map_location=torch.device('cpu'))
66
+ model = MyNeuralNet()
67
+ model.load_state_dict(model_state_dict)
68
+ model.eval()
69
+
70
+ # Use 'model' for predictions
71
+ ```
72
+
73
+ ## Performance
74
+
75
+ 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.
76
+
77
+ ## Limitations and Ethics
78
+
79
+ 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.
80
+
81
+ ## License
82
+
83
+ The MyNeuralNet model is made available under the Apache-2.0 license. For more details, please refer to the LICENSE file in the repository.