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

Class InitializationOnlyStatus

tensorflow/python/training/tracking/util.py:840–908  ·  view source on GitHub ↗

Returned from `Saver.restore` when no checkpoint has been specified. Objects of this type have the same `assert_consumed` method as `CheckpointLoadStatus`, but it always fails. However, `initialize_or_restore` works on objects of both types, and will initialize variables in `InitializationO

Source from the content-addressed store, hash-verified

838
839
840class InitializationOnlyStatus(_LoadStatus):
841 """Returned from `Saver.restore` when no checkpoint has been specified.
842
843 Objects of this type have the same `assert_consumed` method as
844 `CheckpointLoadStatus`, but it always fails. However,
845 `initialize_or_restore` works on objects of both types, and will
846 initialize variables in `InitializationOnlyStatus` objects or restore them
847 otherwise.
848 """
849
850 def __init__(self, graph_view, restore_uid):
851 self._restore_uid = restore_uid
852 self._graph_view = graph_view
853 # Keep a reference to the root, since graph_view might only have a weakref.
854 self._root = graph_view.root
855
856 def assert_consumed(self):
857 """Assertion for consistency with `CheckpointLoadStatus`. Always fails."""
858 raise AssertionError(
859 "No checkpoint specified (save_path=None); nothing is being restored.")
860
861 def assert_existing_objects_matched(self):
862 """Assertion for consistency with `CheckpointLoadStatus`. Always fails."""
863 raise AssertionError(
864 "No checkpoint specified (save_path=None); nothing is being restored.")
865
866 def assert_nontrivial_match(self):
867 """Assertion for consistency with `CheckpointLoadStatus`. Always fails."""
868 raise AssertionError(
869 "No checkpoint specified (save_path=None); nothing is being restored.")
870
871 def run_restore_ops(self, session=None):
872 """For consistency with `CheckpointLoadStatus`.
873
874 Use `initialize_or_restore` for initializing if no checkpoint was passed
875 to `Saver.restore` and restoring otherwise.
876
877 Args:
878 session: Not used.
879 """
880 raise AssertionError(
881 "No checkpoint specified, so no restore ops are available "
882 "(save_path=None to Saver.restore).")
883
884 def initialize_or_restore(self, session=None):
885 """Runs initialization ops for variables.
886
887 Objects which would be saved by `Saver.save` will be initialized, unless
888 those variables are being restored by a later call to
889 `tf.train.Checkpoint.restore()`.
890
891 This method does nothing when executing eagerly (initializers get run
892 eagerly).
893
894 Args:
895 session: The session to run initialization ops in. If `None`, uses the
896 default session.
897 """

Callers 1

restoreMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected