Draft: Keras Fashion-MNIST

This notebook runs on a python environment that contains Keras, Tensorflow and Numpy. It describes a small Machine Learning challenge with a suggested solution to the challenge.

Your mission is to come with a better solution to the challenge and to share it with your colleagues, customers or friends either privately or publicly.

Currently, the notebook is in read-only mode. In order to change the content of a cell, all you need to do is to click on the Remix button on the right of the top bar. Once you are satisfied with your solution, share it by clicking on the Publish button that will appears once you remix the notebook.

1. Setup

There is almost nothing to setup as the "Keras Installation" environment already contains the required python packages.

2. The Challenge

The challenge we propose is to find a good model for the Fashion MNIST dataset.

import keras, tensorflow as tf, numpy as np, matplotlib.pyplot as plt
from keras.datasets import fashion_mnist


(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
train_images = train_images / 255.0
test_images = test_images / 255.0

class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', 
               'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']

Let's visualize the items in the dataset:

fig = plt.figure(figsize=(10,10))
for i in range(25):
  plt.imshow(train_images[i], cmap=plt.cm.binary)

3. The Model

We propose a very simple neural network to start with:

model = keras.Sequential([
  keras.layers.Flatten(input_shape=(28, 28)),
  keras.layers.Dense(4, activation=tf.nn.relu),
  keras.layers.Dense(10, activation=tf.nn.softmax)

Now, we compile the model, using the Adam optimizer and sparse categorical cross entropy


Let's train our model with 5 epochs:

model.fit(train_images, train_labels, epochs=5)

4. Model Evaluation

Let's check how our model performs:

test_loss, test_acc = model.evaluate(test_images, test_labels)
print('Test accuracy:', test_acc)

Acuuracy of 0.7644 on the test set is a good start!

Can you do better? Maybe add more neurons or more layers to the neural network? Or use convolutional layers? Feel free to come up with your own ideas: It's your time to shine!

All you need to do is to click on the "Remix" button on the right of the top bar. Now the notebook becomes your own and you can author it. Once you are satisfied with your model, share it with privately with your colleagues or publicly. It is a simple as clicking on the "Publish" button.

Happy notebooking!