Created
September 3, 2018 10:44
-
-
Save hurss/9769485af5a206b0341fa40d613b2a3e to your computer and use it in GitHub Desktop.
Get Started with Tensorflow for Tensorflow 1.7.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
import tensorflow as tf | |
mnist = tf.keras.datasets.mnist | |
(x_train, y_train),(x_test, y_test) = mnist.load_data() | |
x_train, x_test = x_train / 255.0, x_test / 255.0 | |
# ValueError in here | |
# The first layer in a Sequential model must get an `input_shape` argument. | |
# MNIST data has the array with shape 28 by 28 tuple | |
# put 60K array into 1D-convolution layer | |
model = tf.keras.models.Sequential([ | |
tf.keras.layers.Conv1D(60000, 1, 1, input_shape=(28, 28)), # insert here | |
tf.keras.layers.Flatten(), | |
tf.keras.layers.Dense(512, activation=tf.nn.relu), | |
tf.keras.layers.Dropout(0.2), | |
tf.keras.layers.Dense(10, activation=tf.nn.softmax) | |
]) | |
model.compile(optimizer='adam', | |
loss='sparse_categorical_crossentropy', | |
metrics=['accuracy']) | |
model.fit(x_train, y_train, epochs=5) | |
model.evaluate(x_test, y_test) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: https://www.tensorflow.org/tutorials/