Skip to main content
  1. Posts/

Learning Machine Learning with Handwritten Digits

··309 words·2 mins·

🤖 Learning Machine Learning with MNIST
#

👉 Handwritten Digit Recognition is a classic starter project in computer vision.
The goal is to identify numbers from 0 through 9 using images from the famous MNIST dataset.

🚀 Why is it useful?
#

  • It’s simple ✅
  • Helps you understand how convolutional neural networks (CNNs) work
  • Introduces image preparation: resizing and normalizing
  • In the end you test the model with new images → it works!

🧠 Brief explanation
#

Imagine teaching a computer to see like you do: a CNN automatically learns pixel patterns that make a “3” different from a “7.”
First we normalize the data so values range from 0 to 1. Then we train the network with thousands of examples.
Finally, we feed a new image and the network tells us which number it thinks it is.


💻 Code example (Python)
#

import tensorflow as tf
from tensorflow.keras import layers, models
mnist = tf.keras.datasets.mnist

(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

model = models.Sequential([
    layers.Reshape((28, 28, 1), input_shape=(28, 28)),
    layers.Conv2D(32, 3, activation='relu'),
    layers.MaxPooling2D(),
    layers.Flatten(),
    layers.Dense(10, activation='softmax')
])

model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])
model.fit(x_train, y_train, epochs=3)
print("Test accuracy:", model.evaluate(x_test, y_test)[1])

✨ Conclusion
#

This project is ideal for beginners because:

  • No prior experience is needed 🙅‍♂️
  • You use an accessible, well-documented dataset 📂
  • You learn the basic steps: preprocessing → training → evaluation
  • And most importantly, you see results quickly! 🏁

💡 Tip: play with layers and hyperparameters to improve accuracy and watch your model evolve.

More information at the link 👇

More in the following external reference.
Also published on LinkedIn.
Juan Pedro Bretti Mandarano
Author
Juan Pedro Bretti Mandarano