O'Reilly logo

Machine Learning with Swift by Alexander Sosnovshchenko

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required