Created
December 11, 2019 06:19
-
-
Save MortisHuang/3c511e83ecfbcca878ed1436a15c5b32 to your computer and use it in GitHub Desktop.
Test TensorFlow 2.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import, division, print_function, unicode_literals | |
# TensorFlow and tf.keras | |
import tensorflow as tf | |
from tensorflow import keras | |
# import matplotlib.pyplot as plt | |
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 | |
model = keras.Sequential([ | |
keras.layers.Flatten(input_shape=(28, 28)), | |
keras.layers.Dense(128, activation='relu'), | |
keras.layers.Dense(10, activation='softmax') | |
]) | |
model.compile(optimizer='adam', | |
loss='sparse_categorical_crossentropy', | |
metrics=['accuracy']) | |
model.fit(train_images, train_labels, epochs=10) | |
test_loss, test_acc = model.evaluate(test_images, test_labels, verbose=2) | |
print('\nTest accuracy:', test_acc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment