Reputation: 771
I built a Tensorflow RNN model and would like to inspect the models results (e.g. which features/variables are used and how strongly etc.)
I have created the following files:
But I have issues to read those files. I found the following code:
from tensorflow.python import pywrap_tensorflow
model_file = "/trained/checkpoint"
reader = pywrap_tensorflow.NewCheckpointReader(model_file)
var_to_shape_map = reader.get_variable_to_shape_map()
for key in sorted(var_to_shape_map):
print("tensor_name: ", key)
print(reader.get_tensor(key))
I get the following error:
checkpoint: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
Is checkpoint the wrong file? it has no extension in my folder, it just says Type is Data?
Any help would be great!
Upvotes: 2
Views: 1885
Reputation: 1088
You can inspect the tensor of your checkpoints with inspect_checkpoint
function from the tensorflow python tools.
Example from tensorflow doc:
# import the inspect_checkpoint library
from tensorflow.python.tools import inspect_checkpoint as chkp
# print all tensors in checkpoint file
chkp.print_tensors_in_checkpoint_file("/tmp/model.ckpt", tensor_name='', all_tensors=True)
# tensor_name: v1
# [ 1. 1. 1.]
# tensor_name: v2
# [-1. -1. -1. -1. -1.]
https://www.tensorflow.org/guide/saved_model#inspect_variables_in_a_checkpoint
Upvotes: 1