commit 1b9872187d386235388566ff200a68b0e0332d5c Author: Michael Mandl Date: Thu Dec 27 16:47:45 2018 +0100 Initial commit diff --git a/flow.py b/flow.py new file mode 100755 index 0000000..62a8ca3 --- /dev/null +++ b/flow.py @@ -0,0 +1,51 @@ +#!/usr/bin/python3 + +import tensorflow as tf +from tensorflow import keras + +import numpy as np +import matplotlib.pyplot as plt + +import random + +print(tf.__version__) + +fashion_mnist = keras.datasets.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", +] + +model = keras.Sequential( + [ + keras.layers.Flatten(input_shape=(28, 28)), + keras.layers.Dense(128, activation=tf.nn.relu), + keras.layers.Dense(10, activation=tf.nn.softmax), + ] +) + +model.compile( + optimizer=tf.train.AdamOptimizer(), + loss="sparse_categorical_crossentropy", + metrics=["accuracy"], +) + +model.fit(train_images, train_labels, epochs=5) + +test_loss, test_acc = model.evaluate(test_images, test_labels) + +print("Test accuracy:", test_acc)