Last active
January 24, 2020 12:30
-
-
Save junhua/dc697c527ec426b324e319a32455c70f to your computer and use it in GitHub Desktop.
TF2 sample
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
import tensorflow as tf | |
# print(tf.__version__) | |
mnist = tf.keras.datasets.mnist | |
(training_images, training_labels) , (test_images, test_labels) = mnist.load_data() | |
training_images = training_images/255.0 | |
test_images = test_images/255.0 | |
model = tf.keras.models.Sequential([tf.keras.layers.Flatten(), | |
tf.keras.layers.Dense(1024, activation=tf.nn.relu), | |
tf.keras.layers.Dense(10, activation=tf.nn.softmax)]) | |
model.compile(optimizer = 'adam', | |
loss = 'sparse_categorical_crossentropy') | |
model.fit(training_images, training_labels, epochs=5) | |
model.evaluate(test_images, test_labels) | |
classifications = model.predict(test_images) | |
print(classifications[0]) | |
print(test_labels[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment