February 2018
Intermediate to advanced
262 pages
6h 59m
English
We have created the model and optimizer. Since we are using the Dogs vs. Cats dataset, we can use the same data loaders and the train function to train our model. Remember, when we train the model, only the parameters inside the classifier change. The following code snippet will train the model for 20 epochs, reaching a validation accuracy of 98.45%:
train_losses , train_accuracy = [],[]val_losses , val_accuracy = [],[]for epoch in range(1,20): epoch_loss, epoch_accuracy = fit(epoch,vgg,train_data_loader,phase='training') val_epoch_loss , val_epoch_accuracy = fit(epoch,vgg,valid_data_loader,phase='validation') train_losses.append(epoch_loss) train_accuracy.append(epoch_accuracy) val_losses.append(val_epoch_loss) ...