Skip to content

Instantly share code, notes, and snippets.

@cafielo
Created October 31, 2017 15:36
Show Gist options
  • Save cafielo/111090556b49731b5b0915030553d2c5 to your computer and use it in GitHub Desktop.
Save cafielo/111090556b49731b5b0915030553d2c5 to your computer and use it in GitHub Desktop.
4. train, test and save the model
model.compile(loss=keras.losses.categorical_crossentropy,
optimizer=keras.optimizers.Adam(),
metrics=['accuracy'])
model.fit(x_train, y_train,
batch_size=batch_size,
epochs=epochs,
verbose=2,
validation_data=(x_test, y_test))
score = model.evaluate(x_test, y_test, verbose=1)
print('Test loss:', score[0])
print('Test accuracy:', score[1])
model.save('mnist_keras_cnn_model.h5')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment