Created
October 31, 2017 15:36
-
-
Save cafielo/111090556b49731b5b0915030553d2c5 to your computer and use it in GitHub Desktop.
4. train, test and save the model
This file contains hidden or 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
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