Neural Network Programming - Deep Learning with PyTorch

with deeplizard.

Data in Deep Learning (Important) - Fashion MNIST for Artificial Intelligence

October 17, 2018 by

Blog

Introducing Fashion-MNIST for machine learning

Welcome back to this series on neural network programming. In this post, we will introduce the Fashion-MNIST dataset.

cyborg ai

We’ll look at the dataset spec, how the dataset was built, and how the dataset differs from the original MNIST dataset of handwritten digits. Without further ado, let’s get started.

Why study a dataset?

Let’s kick things off by pondering the question of why we should take the time to study a dataset. Data is the primary ingredient of deep learning, and although it’s our task as neural network programmers to let our neural networks learn from our data, we still have the responsibility of knowing the nature and history of the data we are using to actually do the training.

Computer programs in general consist of two primary components, code and data. With traditional programming, the programmer’s job is to directly write the software or code, but with deep learning and neural networks, the software so to speak is the network itself and in particular, the network’s weights that emerge automatically during the training process.

weights

It’s the programmer’s job to oversee and guide the learning process though training. We can think of this as an indirect way of writing software or code. By using data and deep learning, neural network programmers can produce software capable of performing computations without writing code to explicitly carry out these computations.

For this reason, the role of data in developing software is shifting, and we’ll likely see the role of software developers shift as well.

Data focused considerations:

  • Who created the dataset?
  • How was the dataset created?
  • What transformations were used?
  • What intent does the dataset have?
  • Possible unintentional consequences?
  • Is the dataset biased?
  • Are there ethical issues with the dataset?

In practice, acquiring and accessing data is often of the hardest parts of deep learning, so keep this in mind as we go though this particular dataset. Take note of the general concepts and ideas that we see here.

What is the MNIST dataset?

The MNIST dataset, Modified National Institute of Standards and Technology database, is a famous dataset of handwritten digits that is commonly used for training image processing systems for machine learning. NIST stands for National Institute of Standards and Technology.

The M in MNIST stands for modified, and this is because there was an original NIST dataset of digits that was modified to give us MNIST.

mnist dataset samples

MNIST is famous because of how often the dataset is used. It’s common for two reasons:

  1. Beginners use it because it’s easy
  2. Researchers use it to benchmark (compare) different models.

The dataset consists of 70,000 images of hand written digits with the following split:

  • 60,000 training images
  • 10,000 testing images

The images were originally created by American Census Bureau employees and American high school students.

MNIST has been so widely used, and image recognition tech has improved so much that the dataset is considered to be too easy. This is why the Fashion-MNIST dataset was created.

What is Fashion-MNIST?

Fashion-MNIST as the name suggests is a dataset of fashion items. Specifically, the dataset has the following ten classes of fashion items:

Index Label
0 T-shirt/top
1 Trouser
2 Pullover
3 Dress
4 Coat
5 Sandal
6 Shirt
7 Sneaker
8 Bag
9 Ankle boot

As we have seen in a previous post, a sample of the items look like this:

fashion mnist examples

What's the origin of Fashion-MNIST

Where did the Fashion-MNIST images come from? Fashion-MNIST is based on the assortment on Zalando’s website. Zalando is a German based multi-national fashion commerce company that was founded in 2008.

This is why we see zalandoresearch in the GitHub URL where the Fashion-MNIST dataset is available for download.

Zalando Research is the group from within the company that created the dataset.

We’ll see more about how the images were collected when we review the paper that introduced the dataset, but first, let’s answer another lurking question.

What’s MNIST about a fashion dataset?

What puts the MNIST in Fashion-MNIST?

The reason the fashion MNIST dataset has MNIST in it’s name is because the creators seek to replace the MNIST with Fashion-MNIST.

For this reason, the Fashion dataset was designed to mirror the original MNIST dataset as closely as possible while introducing higher difficulty in training due to simply having more complex data than hand written images.

We’ll see the specific ways that Fashion-MNIST mirrors the original dataset in the paper, but one thing we have already seen is the number of classes.

  • MNIST – has 10 classes (one for each digit 0-9)
  • Fashion-MNIST – has 10 classes (this is intentional)

Let’s check out the paper.

Reading the Fashion-MNIST paper on arXiv

The paper can be found here, and to see the paper, just click on the PDF link.

arxiv logo

The first thing to notice about the paper is that the authors are from Zalando Research (the origin of Fashion-MNIST).

After reading the paper’s abstract, we see why the dataset has been named Fashion-MNIST.

The Fashion-MNIST paper's abstract

We present Fashion-MNIST, a new dataset comprising of 28 by 28 grayscale images of 70,000 fashion products from 10 categories, with 7,000 images per category. The training set has 60,000 images and the test set has 10,000 images. Fashion-MNIST is intended to serve as a direct dropin replacement for the original MNIST dataset for benchmarking machine learning algorithms, as it shares the same image size, data format and the structure of training and testing splits. The dataset is freely available at https://github.com/zalandoresearch/fashion-mnist.

The dataset was designed to be a drop-in replacement for the original MNIST. By making the Fashion-MNIST dataset specs match the original MNIST specs, the switch over from old to new can be smooth. The paper claims that the only change needed to switch datasets is to change the URL from where the MNIST dataset is fetched by pointing to the Fashion dataset.

The paper also give us some more insight as to why MNIST is so popular:

The reason MNIST is so popular has to do with its size, allowing deep learning researchers to quickly check and prototype their algorithms. This is also complemented by the fact that all machine learning libraries (e.g. scikit-learn) and deep learning frameworks (e.g. Tensorflow, PyTorch) provide helper functions and convenient examples that use MNIST out of the box.

PyTorch does provide us with a package called torchvision that makes it easy for us to get started with MNIST as well as Fashion-MNIST.

We’ll be using torchvision in our next post to load our training set into our project.

How Fashion-MNIST was built

Unlike the MNIST dataset, the fashion set wasn’t hand-drawn, but the images in the dataset are actual images from Zalando’s website.

However, they have been transformed to more closely correspond to the MNIST specifications. This is the general conversion process that each image from the site went through:

  1. Converted to PNG
  2. Trimmed
  3. Resized
  4. Sharpened
  5. Extended
  6. Negated
  7. Gray-scaled

To see a more detailed description of this process, be sure to check out section two of the paper.

Accessing Fashion-MNIST with torchvision

In summary, we have seen the origin and history of the Fashion-MNIST dataset, and although the dataset is designed to be more challenging as a computer vision problem, the set is still a great place to start.

pytorch logo

We will be accessing Fashion-MNIST though a PyTorch vision library called torchvision and building our first neural network that can accurately predict an output class given an input fashion image.

I’ll see you in the next one.

Description

This series is all about neural network programming and artificial intelligence. In this post, we will look closely at the importance of data in deep learning by exploring cutting edge concepts in software development, and taking a deep dive into a relatively new dataset. References: Urs Bergmann: https://youtu.be/JBl8pcmPHog Andrej Karpathy & Anima Anandkumar: https://youtu.be/KJAnSyB6mME 💥🦎 DEEPLIZARD COMMUNITY RESOURCES 🦎💥 👀 OUR VLOG: 🔗 https://www.youtube.com/channel/UC9cBIteC3u7Ee6bzeOcl_Og 👉 Check out the blog post and other resources for this video: 🔗 https://deeplizard.com/learn/video/EqpzfvxBx30 💻 DOWNLOAD ACCESS TO CODE FILES 🤖 Available for members of the deeplizard hivemind: 🔗 https://www.patreon.com/posts/27743395 🧠 Support collective intelligence, join the deeplizard hivemind: 🔗 https://deeplizard.com/hivemind 🤜 Support collective intelligence, create a quiz question for this video: 🔗 https://deeplizard.com/create-quiz-question 🚀 Boost collective intelligence by sharing this video on social media! ❤️🦎 Special thanks to the following polymaths of the deeplizard hivemind: yasser Prash 👀 Follow deeplizard: Our vlog: https://www.youtube.com/channel/UC9cBIteC3u7Ee6bzeOcl_Og Twitter: https://twitter.com/deeplizard Facebook: https://www.facebook.com/Deeplizard-145413762948316 Patreon: https://www.patreon.com/deeplizard YouTube: https://www.youtube.com/deeplizard Instagram: https://www.instagram.com/deeplizard/ 🎓 Other deeplizard courses: Reinforcement Learning - https://deeplizard.com/learn/playlist/PLZbbT5o_s2xoWNVdDudn51XM8lOuZ_Njv NN Programming - https://deeplizard.com/learn/playlist/PLZbbT5o_s2xrfNyHZsM6ufI0iZENK9xgG DL Fundamentals - https://deeplizard.com/learn/playlist/PLZbbT5o_s2xq7LwI2y8_QtvuXZedL6tQU Keras - https://deeplizard.com/learn/playlist/PLZbbT5o_s2xrwRnXk_yCPtnqqo4_u2YGL TensorFlow.js - https://deeplizard.com/learn/playlist/PLZbbT5o_s2xr83l8w44N_g3pygvajLrJ- Data Science - https://deeplizard.com/learn/playlist/PLZbbT5o_s2xrth-Cqs_R9- Trading - https://deeplizard.com/learn/playlist/PLZbbT5o_s2xr17PqeytCKiCD-TJj89rII 🛒 Check out products deeplizard recommends on Amazon: 🔗 https://www.amazon.com/shop/deeplizard 📕 Get a FREE 30-day Audible trial and 2 FREE audio books using deeplizard’s link: 🔗 https://amzn.to/2yoqWRn 🎵 deeplizard uses music by Kevin MacLeod 🔗 https://www.youtube.com/channel/UCSZXFhRIx6b0dFX3xS8L1yQ 🔗 http://incompetech.com/ ❤️ Please use the knowledge gained from deeplizard content for good, not evil.