Loading a pre-trained model to speed up the training
In this section, let's focus on loading the pre-trained model in TensorFlow. We will use the VGG-16 model proposed by K. Simonyan and A. Zisserman from the University of Oxford.
VGG-16 is a very deep neural network with lots of convolution layers followed by max-pooling and fully connected layers. In the ImageNet
challenge, the top-5 classification error of the VGG-16 model on the validation set of 1,000 image classes is 8.1% in a single-scale approach:

First, create a file named nets.py
in the project
directory. The following code defines the graph for the VGG-16 model:
import tensorflow as tf import numpy as np def inference(images): with tf.name_scope("preprocess"): mean = tf.constant([123.68, 116.779, 103.939], dtype=tf.float32, shape=[1, 1, 1, 3], name='img_mean') input_images = images - mean conv1_1 = _conv2d(input_images, 3, 3, 64, 1, 1, name="conv1_1") conv1_2 = _conv2d...