Difficulty: beginner
Estimated Time: 10 minutes

TensorFlow is the platform enabling building deep Neural Network architectures and perform Deep Learning. This scenario shows how to use TensorFlow to the classification task. the training is performed on the MNIST dataset that is considered a Hello world for the deep learning examples. The content is based on the official TensorFlow tutorial.

To take the most of this course you should know how to program in Python or other language that would allow you to understand Python syntax.


You've completed TensorFlow: MNIST for beginners scenario.

You've learned how to perform the following tasks:

  • Download MNIST dataset
  • Define placeholders and variables for the classification process
  • Build dense output layer
  • Use loss function and optimise it with gradient descent
  • Run the neural network training
  • Evaluate the model

TensorFlow: MNIST for beginners

Step 1 of 6

Loading MNIST dataset

This scenario is an introduction to how to use TensorFlow when building a simple neural network architecture, training the model and evaluate the results. We will be working on the MNIST dataset. We will be solving the classification task and try to recognise the actual digit from its handwritten representation.

MNIST Classification

TensorFlow has the dataset already built in, so there is no need to manually download it.

To start working with MNIST let us include some necessary imports:

import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data

# Read data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)

The code uses built-in capabilities of TensorFlow to download the dataset locally and load it into the python variable. As a result (if not specified otherwise), the data will be downloaded into the MNIST_data/ folder.

We are also defining some of the values that will be use further in the code:

image_size = 28
labels_size = 10
learning_rate = 0.05
steps_number = 1000
batch_size = 100