Image classification using retrained Inception v3 in TensorFlow

The retraining of Inception v3 differs from the VGG16, as we use the softmax activation layer for the output with tf.losses.softmax_cross_entropy() as the loss function.

  1. First define the placeholders:
is_training = tf.placeholder(tf.bool,name='is_training')x_p = tf.placeholder(shape=(None,                            image_height,                             image_width,                            3                           ),                     dtype=tf.float32,                     name='x_p')y_p = tf.placeholder(shape=(None,coco.n_classes),                     dtype=tf.int32,                     name='y_p')
  1. Next, load the model:
with slim.arg_scope(inception.inception_v3_arg_scope()):    logits,_ = inception.inception_v3(x_p,                                      num_classes=coco.n_classes,                                      is_training=True                                     )probabilities = tf.nn.softmax(logits)
  1. Next, define functions to restore the variables ...

Get Mastering TensorFlow 1.x now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.