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

Method stop_recording

tensorflow/python/eager/backprop.py:864–893  ·  view source on GitHub ↗

Temporarily stops recording operations on this tape. Operations executed while this context manager is active will not be recorded on the tape. This is useful for reducing the memory used by tracing all computations. For example: ``` with tf.GradientTape(persistent=True)

(self)

Source from the content-addressed store, hash-verified

862
863 @tf_contextlib.contextmanager
864 def stop_recording(self):
865 """Temporarily stops recording operations on this tape.
866
867 Operations executed while this context manager is active will not be
868 recorded on the tape. This is useful for reducing the memory used by tracing
869 all computations.
870
871 For example:
872
873 ```
874 with tf.GradientTape(persistent=True) as t:
875 loss = compute_loss(model)
876 with t.stop_recording():
877 # The gradient computation below is not traced, saving memory.
878 grads = t.gradient(loss, model.variables)
879 ```
880
881 Yields:
882 None
883 Raises:
884 RuntimeError: if the tape is not currently recording.
885 """
886 if self._tape is None:
887 raise RuntimeError(
888 "Trying to stop recording a tape which is not recording.")
889 self._pop_tape()
890 try:
891 yield
892 finally:
893 self._push_tape()
894
895 def reset(self):
896 """Clears all information stored in this tape.

Callers 9

compute_gradientsFunction · 0.80
init_scopeFunction · 0.80
callMethod · 0.80
testTapeStopRecordingMethod · 0.80
create_mirrored_variableFunction · 0.80
CreateInstancesMethod · 0.80
CreateInstancesMethod · 0.80

Calls 2

_pop_tapeMethod · 0.95
_push_tapeMethod · 0.95

Tested by 3

compute_gradientsFunction · 0.64
testTapeStopRecordingMethod · 0.64