Training the Keras model

Now that our network has been built and compiled, all that's left is to train it. Much like in Python's scikit-learn, you can do that by calling .fit() on the model instance, as shown in the following code:

model.fit(x=data["train_X"], y=data["train_y"], batch_size=32, epochs=200, verbose=1, validation_data=(data["val_X"], data["val_y"]))

Let us walk through a few of the important arguments the Keras fit method takes. I will assume that you're familiar with mini-batch gradient descent and training epochs but if you aren't, please check Chapter 1, The Building Blocks of Deep Learning, for an overview. The important arguments in the Keras fit model are as follows:

  • batch_size: Keras defaults to a batch size of 32. The ...

Get Deep Learning Quick Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.