...

/

Implementing Our First Neural Network

Implementing Our First Neural Network

Learn to implement, train, and validate a neural network to classify handwritten digits.

Let’s implement a neural network. Specifically, we will implement a fully connected neural network (FCNN) model.

One of the stepping stones to the introduction of neural networks is to implement a neural network that is able to classify digits. For this task, we’ll be using the famous MNIST dataset.

We might feel a bit skeptical regarding our using a computer vision task rather than an NLP task. However, vision tasks can be implemented with less preprocessing and are easy to understand.

Because this is our first encounter with neural networks, we’ll see how to implement this model using Keras. Keras is the high-level submodule that provides a layer of abstraction over TensorFlow. Therefore, we can implement neural networks with much less effort with Keras than using TensorFlow’s raw operations.

Press + to interact
Fully connected neural network (FCNN)
Fully connected neural network (FCNN)

Preparing the data

First, we need to download the dataset. TensorFlow, out of the box, provides convenient functions to download data, and MNIST is one of those supported datasets.

We will be performing four important steps during the data preparation:

Download and store the data

We need to download the data and store it as numpy.ndarray objects. We’ll create a folder named data within our directory and store the data there.

The following ...