In this section, we will train the model.
Here, we can see that model.fit helps us start the training process:
# Display training progress by printing a single dot for each completed epoch In[32]: class PrintDot(keras.callbacks.Callback): def on_epoch_end(self, epoch, logs): if epoch % 100 == 0: print('') print('.', end='') In[33]: EPOCHS = 1000 In[34]: history = model.fit(normed_train_data, train_labels, epochs=EPOCHS, validation_split = 0.2, verbose=0, callbacks=[PrintDot()])
Now, we will visualize the model's training progress:
In[35]: hist = pd.DataFrame(history.history)
In[36]: hist['epoch'] = history.epoch
In[37]: hist.tail()
In[38]: def plot_training_history(history):
hist = pd.DataFrame(history.history)
hist['epoch'] = history.epoch
plt.figure()
plt.xlabel('Epoch')
plt.ylabel('Mean Abs Error [MPG]')
...