项目作者: 360macky

项目描述 :
👚⚙️ A fashion-item classifier developed with TensorFlow 2.0.0
高级语言: Jupyter Notebook
项目地址: git://github.com/360macky/FashionItem-Classifier.git
创建时间: 2019-11-24T21:24:28Z
项目社区:https://github.com/360macky/FashionItem-Classifier

开源协议:

下载


👚 Fashion Item Classifier ⚙️

A fashion item classifier developed with TensorFlow 2.0.0 and Keras.








It is based of the popular fashion_mnist dataset of Keras:

MNIST Dataset
TensorFlow

📦 Deployment

It’s important install TensorFlow 2.0.0 with PIP using:

  1. pip install tensorflow==2.0.0-alpha0

Then install other libraries like:

  • Pandas
  • Numpy
  • Matplotlib

With its latest version using PIP.

🚀 How it works?

📊 Reading data

Load MNIST Fashion-item dataset:

  1. data = keras.datasets.fashion_mnist
  2. (train_images, train_labels), (test_images, test_labels) = data.load_data()

The dataset split train_images and test_images are numpy type array with 784 numbers from 0 to 255. These arrays can be converted into images of 28 by 28 pixels (that’s why 784 numbers).

Then reduce the data dividing by 225, beacuse is a good practice shrink our data. Now the values of 225 is equal to 1.0 and so on:

  1. train_images = train_images / 255.0
  2. test_images = test_images / 255.0

Based on the labels for each fashion item, create a list for ten elements:

  1. class_names = ['T-shirt/top',
  2. 'Trouser',
  3. 'Pullover',
  4. 'Dress',
  5. 'Coat',
  6. 'Sandal',
  7. 'Shirt',
  8. 'Sneaker',
  9. 'Bag',
  10. 'Ankle boot']

🧠 Neural Network Development

Using Sequential class from Keras and add layers.

  1. The first layer is flattening input data based on 28x28 pixels of the image.
  2. Then, the second layer receive the data from the previous layer and works with it with 128 neurons using RELU activation.
  3. The final layer receive the data from the previous layer and works with an ouput of 10 (based on the 10 fashion-item) using SoftMax activation.
  1. model = keras.Sequential([
  2. keras.layers.Flatten(input_shape=(28, 28)),
  3. keras.layers.Dense(128, activation="relu"),
  4. keras.layers.Dense(10, activation="softmax")
  5. ])

Building the Neural Network

Using compile method of Sequential using the necessary parameters:

  • Optimizer: Set as adam, an optimizing algorithm.
  • Loss: Set as sparse_categorical_crossentropy
  1. model.compile(
  2. optimizer="adam",
  3. loss="sparse_categorical_crossentropy",
  4. metrics=["accuracy"]
  5. )