Training the network

First, we have to define how long we want to train out network. One epoch is one full pass over the training set. The number of steps in the epoch depends on the batch size and the number of samples in the training set. Let's say we want to pass over the training set 100 times:

num_epochs = 100

Fit the model on batches with real-time data augmentation:

num_epochs = 100 # we iterate 200 times over the entire training set history = model.fit_generator(train_flow, steps_per_epoch=len(X_train) / batch_size, epochs=num_epochs, verbose=1, validation_data=test_flow, validation_steps=len(X_test) / batch_size) Epoch 1/100 883/883 [==============================] - 15s - loss: 1.7065 - acc: 0.2836 - val_loss: 1.8536 - val_acc: ...

Get Machine Learning with Swift 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.