Complete the code to train the model and save the training history.
history = model.fit(X_train, y_train, epochs=[1], validation_split=0.2)
The epochs parameter sets how many times the model will see the entire training data. Here, 10 epochs is a common choice for a simple training.
Complete the code to plot training accuracy from the history object.
plt.plot(history.history['[1]'])
The history.history dictionary stores metrics by their names. To plot training accuracy, use the key 'accuracy'.
Fix the error in the code to plot validation loss correctly.
plt.plot(history.history['[1]'])
The correct key for validation loss in history.history is 'val_loss'. Other keys will cause errors or wrong plots.
Fill both blanks to plot training and validation accuracy.
plt.plot(history.history['[1]'], label='train') plt.plot(history.history['[2]'], label='validation') plt.legend()
To compare training and validation accuracy, plot 'accuracy' and 'val_accuracy' from the history.
Fill all three blanks to create a dictionary of training loss, validation loss, and epochs.
results = {
'[1]': history.history['loss'],
'[2]': history.history['val_loss'],
'[3]': list(range(1, len(history.history['loss']) + 1))
}This dictionary stores training loss as 'train_loss', validation loss as 'validation_loss', and the epoch numbers as 'epochs'.