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

Method watch

tensorflow/python/eager/backprop.py:837–861  ·  view source on GitHub ↗

Ensures that `tensor` is being traced by this tape. Args: tensor: a Tensor or list of Tensors. Raises: ValueError: if it encounters something that is not a tensor.

(self, tensor)

Source from the content-addressed store, hash-verified

835 pass
836
837 def watch(self, tensor):
838 """Ensures that `tensor` is being traced by this tape.
839
840 Args:
841 tensor: a Tensor or list of Tensors.
842
843 Raises:
844 ValueError: if it encounters something that is not a tensor.
845 """
846 for t in nest.flatten(tensor):
847 if not (pywrap_tensorflow.IsTensor(t) or
848 pywrap_tensorflow.IsVariable(t)):
849 raise ValueError("Passed in object of type {}, not tf.Tensor".format(
850 type(t)))
851 if not t.dtype.is_floating:
852 logging.log_first_n(
853 logging.WARN, "The dtype of the watched tensor must be "
854 "floating (e.g. tf.float32), got %r", 5, t.dtype)
855 if hasattr(t, "handle"):
856 # There are many variable-like objects, all of them currently have
857 # `handle` attribute that points to a tensor. If this changes, internals
858 # of watch_variable need to change as well.
859 tape.watch_variable(self._tape, t)
860 else:
861 tape.watch(self._tape, t)
862
863 @tf_contextlib.contextmanager
864 def stop_recording(self):

Callers 15

testWatchBadThingMethod · 0.95
test_downsampleMethod · 0.45
backward_gradsMethod · 0.45
compute_gradientsMethod · 0.45
compute_gradientsMethod · 0.45
gMethod · 0.45
testGradientTapeMethod · 0.45

Calls 5

typeFunction · 0.85
IsVariableMethod · 0.80
watch_variableMethod · 0.80
flattenMethod · 0.45
formatMethod · 0.45

Tested by 15

testWatchBadThingMethod · 0.76
test_downsampleMethod · 0.36
gMethod · 0.36
testGradientTapeMethod · 0.36
testBatchDimsMethod · 0.36
gradMethod · 0.36
fMethod · 0.36
fMethod · 0.36