Checkpointing model
Training a deep neural network is an expensive process in terms of time, storage, and resources. Retraining a network each time we want to use it is preposterous and impractical. The good news is that we can use a mechanism to automatically save the best versions of a network during the training process.
In this recipe, we'll talk about such a mechanism, known as checkpointing.
How to do it…
Follow these steps to learn about the different modalities of checkpointing you have at your disposal in TensorFlow:
- Import the modules we will be using:
import numpy as np import tensorflow as tf from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelBinarizer from tensorflow.keras.callbacks import ModelCheckpoint from tensorflow.keras.datasets import fashion_mnist as fm from tensorflow.keras.layers import * from tensorflow.keras.models import *
- Define a function that will load
Fashion-MNIST
intotf.data...