Data Science & Machine Learning 101

Data Science & Machine Learning 101

Share this post

Data Science & Machine Learning 101
Data Science & Machine Learning 101
Deep Learning 2 - Your First Neural Network

Deep Learning 2 - Your First Neural Network

MNIST, architecture, compiling, data prep, training, predicting

BowTied_Raptor's avatar
BowTied_Raptor
Feb 17, 2025
∙ Paid
3

Share this post

Data Science & Machine Learning 101
Data Science & Machine Learning 101
Deep Learning 2 - Your First Neural Network
Share

One of the best ways to learn neural nets is by doing. So, in this case, we’ll grab a classical dataset, and crack open a neural net, and explain what’s going on.

For this post, you’ll want to ahead, and download the tensorflow, and keras libraries to your python.

1 - MNIST Dataset

Let’s say we want to come up with an algorithm that can analyze handwritten digits, and classify them from 0 to 9. To do this, we’ll need several photos of handwritten digits, and we’ll need them classified for us, so that we can pass the X data (the photos), and the target Y data (classification) to our neural net to see the pattern.

Luckily, this data already exists, it’s called the MNIST digits data. To load this in Python, simply run the following code:

from tensorflow.keras.datasets import mnist
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()

Once you have these pictures loaded, you’ll see that you get a numpy array, where train_images.shape has the following dimensions (60000, 28, 28). This is telling us that our training images data has 60,000 photos, each photo having the length & width of 28.

You can use basic indexing, and matplotlib to plot the images and view them, this is what they look like:

mnist | TensorFlow Datasets

If you are like me, and use Pycharm, you can just click on the variable, and have it load the first one for you. Feel free to guess which number this is:

2 - Network architecture

Keep reading with a 7-day free trial

Subscribe to Data Science & Machine Learning 101 to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 BowTied_Raptor
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share