Do we need more data?
It's time to check whether the digits dataset model you built benefits from more training examples!
In order to keep code to a minimum, various things are already initialized and ready to use:
- The 
modelyou just built. X_train,y_train,X_test, andy_test.- The 
initial_weightsof your model, saved after usingmodel.get_weights(). - A pre-defined list of training sizes: 
training_sizes. - A pre-defined early stopping callback monitoring loss: 
early_stop. - Two empty lists to store the evaluation results: 
train_accsandtest_accs. 
Train your model on the different training sizes and evaluate the results on X_test.
End by plotting the results with plot_results().
The full code for this exercise can be found on the slides!
Diese Übung ist Teil des Kurses
Introduction to Deep Learning with Keras
Anleitung zur Übung
- Get a fraction of the training data determined by the 
sizewe are currently evaluating in the loop. - Set the model weights to the 
initial_weightswithset_weights()and train your model on the fraction of training data usingearly_stopas a callback. - Evaluate and store the accuracy for the training fraction and the test set.
 - Call 
plot_results()passing in the training and test accuracies for each training size. 
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
for size in training_sizes:
  	# Get a fraction of training data (we only care about the training data)
    X_train_frac, y_train_frac = X_train[:size], y_train[:size]
    # Reset the model to the initial weights and train it on the new training data fraction
    model.set_weights(____)
    model.fit(X_train_frac, y_train_frac, epochs = 50, callbacks = [early_stop])
    # Evaluate and store both: the training data fraction and the complete test set results
    train_accs.append(model.evaluate(____, ____)[1])
    test_accs.append(model.evaluate(____, ____)[1])
    
# Plot train vs test accuracies
plot_results(____, ____)