![]() |
Lists the checkpoint keys and shapes of variables in a checkpoint.
tf.train.list_variables(
ckpt_dir_or_file
)
Checkpoint keys are paths in a checkpoint graph.
Example usage | |||||||||
---|---|---|---|---|---|---|---|---|---|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license. Last updated 2023-03-17 UTC.
[null,null,["Last updated 2023-03-17 UTC."],[],[],null,["# tf.train.list_variables\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.9.3/tensorflow/python/training/checkpoint_utils.py#L85-L115) |\n\nLists the checkpoint keys and shapes of variables in a checkpoint.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.train.list_variables`](https://www.tensorflow.org/api_docs/python/tf/train/list_variables)\n\n\u003cbr /\u003e\n\n tf.train.list_variables(\n ckpt_dir_or_file\n )\n\nCheckpoint keys are paths in a checkpoint graph.\n\n\u003cbr /\u003e\n\n| Example usage ------------- ||\n|---|---|\n| \u003cbr /\u003e \u003c/td\u003e \u003c/tr\u003e \u003c/table\u003e import tensorflow as tf import os ckpt_directory = \"/tmp/training_checkpoints/ckpt\" ckpt = tf.train.Checkpoint(optimizer=optimizer, model=model) manager = tf.train.CheckpointManager(ckpt, ckpt_directory, max_to_keep=3) train_and_checkpoint(model, manager) tf.train.list_variables(manager.latest_checkpoint) \u003cbr /\u003e \u003cbr /\u003e \u003cbr /\u003e | Args ---- || |--------------------|--------------------------------------------------------| | `ckpt_dir_or_file` | Directory with checkpoints file or path to checkpoint. | \u003cbr /\u003e \u003cbr /\u003e \u003cbr /\u003e \u003cbr /\u003e | Returns ------- || |---|---| | List of tuples `(key, shape)`. || \u003cbr /\u003e ||"]]
|