Skip to content

Instantly share code, notes, and snippets.

View mohammedouahman's full-sized avatar
🇵🇸
#StandWithPalestine

Mohammed Ouahman mohammedouahman

🇵🇸
#StandWithPalestine
View GitHub Profile
@mohammedouahman
mohammedouahman / classify.py
Created November 17, 2021 17:52
images classification
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
@mohammedouahman
mohammedouahman / classify.py
Created November 17, 2021 18:07
import the fashion MNIST dataset directly from tensoflow
fashion_mnist = tf.keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
fashion_mnist = tf.keras.datasets.fashion_mnist
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',
'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']
len(train_labels)
# Each label is an integer between 0 and 9:
print(train_labels)
plt.figure()
plt.imshow(train_images[0])
plt.colorbar()
plt.grid(False)
plt.show()
train_images = train_images / 255.0
test_images = test_images / 255.0
plt.figure(figsize=(10,10))
for i in range(25):
plt.subplot(5,5,i+1)
plt.xticks([])
plt.yticks([])
plt.grid(False)
plt.imshow(train_images[i], cmap=plt.cm.binary)
plt.xlabel(class_names[train_labels[i]])
plt.show()
model = tf.keras.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dense(10)
])