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

Method fnWithLoop

tensorflow/python/kernel_tests/while_v2_test.py:119–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117
118 @def_function.function
119 def fnWithLoop(): # pylint: disable=invalid-name
120 with backprop.GradientTape() as tape:
121 _, x = while_loop_v2(
122 lambda i, _: i < 2,
123 lambda i, x: (i + 1, x * v),
124 [0, 2.])
125 return tape.gradient(x, v)
126
127 self.assertAllEqual(fnWithLoop(), 4.0)
128

Callers

nothing calls this directly

Calls 3

while_loop_v2Function · 0.85
gradientMethod · 0.80
GradientTapeMethod · 0.45

Tested by

no test coverage detected