Created
July 6, 2019 13:48
-
-
Save jamesonthecrow/812636bd354260038db15a077e786a37 to your computer and use it in GitHub Desktop.
A tutorial on the Fritz CLI. https://fritz.ai
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 keras | |
from keras.datasets import mnist | |
keras.backend.clear_session() | |
(x_train, y_train), (x_test, y_test) = mnist.load_data() | |
def build_model(): | |
input = keras.layers.Input((28, 28, 1)) | |
out = keras.layers.Conv2D(16, 3, strides=2, activation='relu')(input) | |
out = keras.layers.Conv2D(32, 3, strides=2, activation='relu')(out) | |
out = keras.layers.Flatten()(out) | |
out = keras.layers.Dense(10)(out) | |
out = keras.layers.Activation('softmax')(out) | |
return keras.models.Model(input, out) | |
model = build_model() | |
model.compile( | |
keras.optimizers.Adam(lr=0.001), | |
loss=keras.losses.sparse_categorical_crossentropy, | |
metrics=[keras.metrics.sparse_categorical_accuracy] | |
) | |
batch_size = 32 | |
model.fit( | |
x_train[:, :, :, None], | |
y_train[:, None], | |
epochs=5, | |
batch_size=batch_size, | |
validation_split=0.05 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment