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)
| 1870 | |
| 1871 | |
| 1872 | def 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 | |
| 1892 | def saver_from_object_based_checkpoint(checkpoint_path, |
no test coverage detected