How to check variables in checkpoint file in TensorFlow when TensorFlow cannot find the tools attribute?

I tried to check for breakpoints using the inspect_checkpoint.py code. However, I could not get it to work, because they really did not give an example. I tried the simplest thing that I thought would work:

tf.python.tools.inspect_checkpoint.print_tensors_in_checkpoint_file(file_name='./tmp/mdl_ckpt',tensor_name='',all_tensors='') 

however, I understand that python does not have the tools attribute:

 AttributeError: module 'tensorflow.python' has no attribute 'tools' 

This seems to be an (embarrassingly) trivial error / problem. Does anyone know what is going on? Why can't he find the tools? Also, even if he finds it, how to run the function provided in this file?


Unfortunately, a very close question did not really give an answer on how to get around this problem. The question here is How to find variable names stored in tensorflow breakpoint?

+8
source share
4 answers

Try the following:

 from tensorflow.python.tools.inspect_checkpoint import print_tensors_in_checkpoint_file print_tensors_in_checkpoint_file(file_name='./tmp/mdl_ckpt', tensor_name='', all_tensors=False) 

The all_tensors argument was added with Tensorflow 0.12.0-rc0 .

+15
source

Well, not a check_checkpoint.py binary?

Something like this might work:

 bazel run tensorflow/python/tools:inspect_checkpoint -- --file_name=YOUR_CKPT 

EDIT:

Or without bazel:

Find where the tensor stream is installed and run the command using python :

 python PATH_TO_VENV/lib/python3.6/site-packages/tensorflow/python/tools/inspect_checkpoint.py --file_name=YOUR_CKPT 

For all parameters, see the file itself: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/inspect_checkpoint.py

+2
source

You can also use the command line interface that uses inspect_checkpoint .

0
source

Starting with the latest stable version of TensorFlow 1.13 and the next version of TF 2.0, the easiest way to check for a breakpoint is:

 path = './tmp/mdl_ckpt' get_checkpoint = tf.train.latest_checkpoint(path) #this retrieves the latest checkpoin file form path, but it also can be set manually inspect_list = tf.train.list_variables(get_checkpoint) 

This creates a list of all variable names at a given breakpoint.

0
source

Source: https://habr.com/ru/post/1014438/


All Articles