Sitemap
TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Member-only story

Using TFRecords to Train a CNN on MNIST

A short walkthrough on writing, reading and using TFRecords

6 min readNov 7, 2020

--

When I started with TFRecords, it took me a while to understand its concept. There were so many new things. To save others from this hassle, I have created a hands-on walkthrough based on the MNIST dataset.

Note: this blog post is now available in a more general version which includes more up-to-date concepts. Further, also note that the TFRecord format is not that hard once you’ve got started, which is why I’ve created a hands-on introduction to it. To learn more, after this tutorial I recommend you to consult these two resources.

Overview

The MNIST dataset consists of digitized handwritten digits in black and white. With 28x28x1 per image, they are pretty small. The memory footprint of the complete dataset is only 32 MB.

Dataset overview. By Josef Steppan.

Imports and helper functions

Let us start with the necessary imports; two libraries, os and Tensorflow. Additionally, we set a global variable, AUTOTUNE, which we use later.

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Pascal Janetzky
Pascal Janetzky

Written by Pascal Janetzky

I aim to read and learn, code and move.