Interactive digit recognition in tensorflow.js

(pynenv setup with python 3.9.20) The story so far In my previous post about Convolutional Neural Networks (CNNs), I demonstrated how to train a model for handwritten digit recognition. Now, we’ll take this model further by deploying it in a web application using TensorFlow.js. This post guides you through the process of exporting the trained model and implementing it in an Observable notebook where users can draw digits on a canvas for real-time classification. ...

June 18, 2024 · 4 min · 848 words · Martin Christopher Arnold

CNN for digit recognition

(pynenv setup with python 3.9.20) Convolutional Neural Networks (CNNs) are powerful tools in image recognition tasks. A classic problem solved by CNNs is predicting handwritten digits from the MNIST dataset. Here’s how to train a CNN for handwritten digit classification using TensorFlow’s Keras API in Python. Dataset and Preprocessing The MNIST dataset (delivered in tensorflow.keras.datasets) consists of 70,000 grayscale images, each representing a digit (0–9). We first load the TensorFlow library as tf, preprocess the data by reshaping the images into a 28x28 pixel format with 1 channel (grayscale), and normalize pixel values to the range $[0, 1]$. The labels are one-hot encoded for multi-class classification. ...

June 17, 2024 · 5 min · 920 words · Martin Christopher Arnold