MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / object_graph_key_mapping

Function object_graph_key_mapping

tensorflow/python/training/saver.py:1872–1889  ·  view source on GitHub ↗

Return name to key mappings from the checkpoint. Args: checkpoint_path: string, path to object-based checkpoint Returns: Dictionary mapping tensor names to checkpoint keys.

(checkpoint_path)

Source from the content-addressed store, hash-verified

1870
1871
1872def object_graph_key_mapping(checkpoint_path):
1873 """Return name to key mappings from the checkpoint.
1874
1875 Args:
1876 checkpoint_path: string, path to object-based checkpoint
1877
1878 Returns:
1879 Dictionary mapping tensor names to checkpoint keys.
1880 """
1881 reader = pywrap_tensorflow.NewCheckpointReader(checkpoint_path)
1882 object_graph_string = reader.get_tensor(trackable.OBJECT_GRAPH_PROTO_KEY)
1883 object_graph_proto = (trackable_object_graph_pb2.TrackableObjectGraph())
1884 object_graph_proto.ParseFromString(object_graph_string)
1885 names_to_keys = {}
1886 for node in object_graph_proto.nodes:
1887 for attribute in node.attributes:
1888 names_to_keys[attribute.full_name] = attribute.checkpoint_key
1889 return names_to_keys
1890
1891
1892def saver_from_object_based_checkpoint(checkpoint_path,

Callers 2

restoreMethod · 0.85

Calls 2

get_tensorMethod · 0.45
ParseFromStringMethod · 0.45

Tested by

no test coverage detected