From fbea596371be6350ea348c473b77263725c7ed7d Mon Sep 17 00:00:00 2001 From: Cihan Soylu Date: Fri, 6 Mar 2020 11:59:34 -0500 Subject: [PATCH] Add project 4 utils --- project_utils/project_4_utils.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 project_utils/project_4_utils.py diff --git a/project_utils/project_4_utils.py b/project_utils/project_4_utils.py new file mode 100644 index 0000000..83ccd5f --- /dev/null +++ b/project_utils/project_4_utils.py @@ -0,0 +1,26 @@ +import tensorflow as tf +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt + +CLASS_NAMES = [ 'T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot'] + +def load_data(): + + (x_train, y_train), (x_val, y_val) = tf.keras.datasets.fashion_mnist.load_data() + + x_train = x_train/255. + x_val = x_val/255. + + return x_train, x_test, y_train, y_test + +def plot_data(images, labels): + + images = images * 255. + n = len(images) + + plt.figure(figsize=(10*n,15)) + for i in range(n): + plt.subplot(n,1,i+1) + plt.imshow(images[i].reshape((28,28)), cmap=plt.cm.gray) + plt.title(CLASS_NAMES[labels[i]])