Skip to content

Can't restore the given checkpoint for inception v3 in research/slim #2977

@jlamypoirier

Description

@jlamypoirier

I am trying to use the given pretrained inception v3 model in research/slim, but the weights don't match

import tensorflow as tf
from nets.inception_v3 import inception_v3_base
tf_images = tf.placeholder(tf.float32, [None, 299, 299, 3])
inception,inception_layers=inception_v3_base(tf_images)
saver = tf.train.Saver()
with tf.Session() as sess:
    saver.restore(sess,'models/weights/inception_v3.ckpt')
NotFoundError: Tensor name "InceptionV3/Mixed_5c/Branch_2/Conv2d_0a_1x1/biases" not found in checkpoint files models/weights/inception_v3.ckpt
	 [[Node: save/RestoreV2_30 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2_30/tensor_names, save/RestoreV2_30/shape_and_slices)]]
	 [[Node: save/RestoreV2_184/_5 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_384_save/RestoreV2_184", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]

Looking at the variables they indeed don't match

from tensorflow.python import pywrap_tensorflow
reader = pywrap_tensorflow.NewCheckpointReader('models/weights/inception_v3.ckpt')
var_to_shape_map = reader.get_variable_to_shape_map()
print(sorted(var_to_shape_map))
print([var.name for var in saver._var_list])

For the checkpoint a subsample is:

'InceptionV3/Conv2d_1a_3x3/BatchNorm/beta',
 'InceptionV3/Conv2d_1a_3x3/BatchNorm/moving_mean',
 'InceptionV3/Conv2d_1a_3x3/BatchNorm/moving_variance',
 'InceptionV3/Conv2d_1a_3x3/weights',
 'InceptionV3/Conv2d_2a_3x3/BatchNorm/beta',
 'InceptionV3/Conv2d_2a_3x3/BatchNorm/moving_mean',
 'InceptionV3/Conv2d_2a_3x3/BatchNorm/moving_variance',
 'InceptionV3/Conv2d_2a_3x3/weights',
 'InceptionV3/Conv2d_2b_3x3/BatchNorm/beta',
 'InceptionV3/Conv2d_2b_3x3/BatchNorm/moving_mean',
 'InceptionV3/Conv2d_2b_3x3/BatchNorm/moving_variance',
 'InceptionV3/Conv2d_2b_3x3/weights',
 'InceptionV3/Conv2d_3b_1x1/BatchNorm/beta',
 'InceptionV3/Conv2d_3b_1x1/BatchNorm/moving_mean',
 'InceptionV3/Conv2d_3b_1x1/BatchNorm/moving_variance',
 'InceptionV3/Conv2d_3b_1x1/weights',
 'InceptionV3/Conv2d_4a_3x3/BatchNorm/beta',
 'InceptionV3/Conv2d_4a_3x3/BatchNorm/moving_mean',
 'InceptionV3/Conv2d_4a_3x3/BatchNorm/moving_variance',
 'InceptionV3/Conv2d_4a_3x3/weights',

And for the saver:

'InceptionV3/Conv2d_1a_3x3/weights:0',
 'InceptionV3/Conv2d_1a_3x3/biases:0',
 'InceptionV3/Conv2d_2a_3x3/weights:0',
 'InceptionV3/Conv2d_2a_3x3/biases:0',
 'InceptionV3/Conv2d_2b_3x3/weights:0',
 'InceptionV3/Conv2d_2b_3x3/biases:0',
 'InceptionV3/Conv2d_3b_1x1/weights:0',
 'InceptionV3/Conv2d_3b_1x1/biases:0',
 'InceptionV3/Conv2d_4a_3x3/weights:0',
 'InceptionV3/Conv2d_4a_3x3/biases:0',

Looks like a mismatch with the biases and the batchnorms. I am using tensorflow version 1.4.0 and models commit 69cf6fc if that is relevant. The checkpoint file is taken from inception_v3_2016_08_28.tar.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions