Skip to content

Instantly share code, notes, and snippets.

@thepurpleowl
Created May 7, 2021 17:05
Show Gist options
  • Save thepurpleowl/c37c8d32fc51d962fa33729e379fbb67 to your computer and use it in GitHub Desktop.
Save thepurpleowl/c37c8d32fc51d962fa33729e379fbb67 to your computer and use it in GitHub Desktop.
To check tf.Variable shape, value, type etc in the saved checkpoint
import tensorflow as tf
from tensorflow.python.tools.inspect_checkpoint import print_tensors_in_checkpoint_file
import re
latest_ckp = tf.train.latest_checkpoint('./training_checkpoints')
print_tensors_in_checkpoint_file(latest_ckp, all_tensors=True, tensor_name='')
# to check specific variable in checkpoint
# [print(var.variables) for var in tf.train.list_variables(latest_ckp) if re.match(r'.*decoder/embedding/embeddings/.ATTRIBUTES/.*',var[0])]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment