tensorflow Estimator cannot initialize global variables -


i using tensorflow slim resnet_v2 extract image features. resnet_v2_152.ckpt :resnet_v2_152.ckpt code.

import tensorflow tf  import tensorflow.contrib.slim.python.slim.nets.resnet_v2 resnet_v2   def cnn_model_fn(features, labels, mode):     net, end_points = resnet_v2.resnet_v2_152(inputs=features, is_training=mode == tf.estimator.modekeys.train)     if mode == tf.estimator.modekeys.predict:         return tf.estimator.estimatorspec(mode=mode, predictions=net)     else:         raise notimplementederror('only support predict!')   def parse_filename(filename):     image_string = tf.read_file(filename)     image_decoded = tf.image.decode_jpeg(image_string, channels=3)     image_resized = tf.image.resize_images(image_decoded, [256, 256])     return image_resized   def dataset_input_fn(dataset, num_epochs=none, batch_size=128, shuffle=false, buffer_size=1000, seed=none):     def input_fn():         d = dataset.repeat(num_epochs).batch(batch_size)         if shuffle:             d = d.shuffle(buffer_size)         iterator = d.make_one_shot_iterator()         next_example = iterator.get_next()         return next_example      return input_fn   filenames = sorted(tf.gfile.glob('/root/data/coco/download/val2014/*')) dataset = tf.contrib.data.dataset.from_tensor_slices(filenames).map(parse_filename)  input_fn = dataset_input_fn(dataset, num_epochs=1, batch_size=1, shuffle=false)  estimator = tf.estimator.estimator(model_fn=cnn_model_fn, model_dir=none)  es = estimator.predict(input_fn=input_fn,                        checkpoint_path='/root/data/checkpoints/resnet_v2_152_2017_04_14/resnet_v2_152.ckpt') print(es.__next__())   print("done!") 

and got error this:

2017-09-10 22:06:36.875590: w tensorflow/core/framework/op_kernel.cc:1192] not found: tensor name "resnet_v2_152/block1/unit_1/bottleneck_v2/conv1/biases" not found in checkpoint files /root/data/checkpoints/resnet_v2_152_2017_04_14/resnet_v2_152.ckpt      [[node: save/restorev2_1 = restorev2[dtypes=[dt_float], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save/const_0_0, save/restorev2_1/tensor_names, save/restorev2_1/shape_and_slices)]] traceback (most recent call last):   file "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1327, in _do_call     return fn(*args)   file "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1306, in _run_fn     status, run_metadata)   file "/usr/lib/python3.5/contextlib.py", line 66, in __exit__     next(self.gen)   file "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status     pywrap_tensorflow.tf_getcode(status)) tensorflow.python.framework.errors_impl.notfounderror: tensor name "resnet_v2_152/block1/unit_1/bottleneck_v2/conv1/biases" not found in checkpoint files /root/data/checkpoints/resnet_v2_152_2017_04_14/resnet_v2_152.ckpt      [[node: save/restorev2_1 = restorev2[dtypes=[dt_float], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save/const_0_0, save/restorev2_1/tensor_names, save/restorev2_1/shape_and_slices)]]      [[node: save/restorev2_242/_309 = _recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_1240_save/restorev2_242", tensor_type=dt_float, _device="/job:localhost/replica:0/task:0/gpu:0"]()]] 

i think can solve initialize conv1/biases 0,but tensorflow estimator did not give me such function. how can fix that?


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -