Skip to content

Instantly share code, notes, and snippets.

@hurss
Created September 3, 2018 10:44
Show Gist options
  • Save hurss/9769485af5a206b0341fa40d613b2a3e to your computer and use it in GitHub Desktop.
Save hurss/9769485af5a206b0341fa40d613b2a3e to your computer and use it in GitHub Desktop.
Get Started with Tensorflow for Tensorflow 1.7.0
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)
@hurss
Copy link
Author

hurss commented Sep 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment