Initial commit
This commit is contained in:
commit
1b9872187d
1 changed files with 51 additions and 0 deletions
51
flow.py
Executable file
51
flow.py
Executable file
|
@ -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)
|
Loading…
Reference in a new issue