How Does One Inspect Variables In A Checkpoint File In Tensorflow When Tensorflow Can't Find The Tools Attribute?
I was trying to inspect checkpoints using the code at inspect_checkpoint.py. However, I wasn't able to have it work because they didn't really provide an example. I tried the simpl
Solution 1:
Try this:
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 since Tensorflow 0.12.0-rc0.
Solution 2:
Well, isn't inspect_checkpoint.py a binary?
Something like this might work:
bazel run tensorflow/python/tools:inspect_checkpoint -- --file_name=YOUR_CKPT
EDIT:
Or without bazel:
Find where tensorflow is installed and run the command with python
:
python PATH_TO_VENV/lib/python3.6/site-packages/tensorflow/python/tools/inspect_checkpoint.py --file_name=YOUR_CKPT
For all options, see the file itself: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/inspect_checkpoint.py
Solution 3:
As of latest stable TensorFlow version, 1.13, and in the upcoming TF 2.0, to most straightforward way to inspect a checkpoint 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 in given checkpoint
Solution 4:
You could also use the command line interface that uses inspect_checkpoint
.
Solution 5:
python -m tensorflow.python.tools.inspect_checkpoint --file_name bad_model/epoch-233
python -m tensorflow.python.tools.inspect_checkpoint --file_name bad_model/epoch-233 --all_tensors
python -m tensorflow.python.tools.inspect_checkpoint --file_name bad_model/epoch-233 --all_tensor_names
Post a Comment for "How Does One Inspect Variables In A Checkpoint File In Tensorflow When Tensorflow Can't Find The Tools Attribute?"