(x)
| 128 | |
| 129 | @decorator |
| 130 | def f(x): |
| 131 | x1 = array_ops.identity(x) |
| 132 | with backprop.GradientTape() as t: |
| 133 | t.watch(x) |
| 134 | t.watch(x1) |
| 135 | y1 = x * 2. |
| 136 | y2 = x1 * 3. |
| 137 | loss = y1 + y2 |
| 138 | return t.gradient(loss, [x, x1]) |
| 139 | |
| 140 | self.assertAllClose([2., 3.], f(constant_op.constant(10.))) |
| 141 |