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

Function _compute_gradient_list

tensorflow/python/ops/gradient_checker.py:245–268  ·  view source on GitHub ↗

Compute gradients for a list of x values.

(x,
                           x_shape,
                           y,
                           y_shape,
                           x_init_value=None,
                           delta=1e-3,
                           init_targets=None,
                           extra_feed_dict=None)

Source from the content-addressed store, hash-verified

243
244
245def _compute_gradient_list(x,
246 x_shape,
247 y,
248 y_shape,
249 x_init_value=None,
250 delta=1e-3,
251 init_targets=None,
252 extra_feed_dict=None):
253 """Compute gradients for a list of x values."""
254 assert isinstance(x, list)
255 dx, dy = zip(*[_compute_dx_and_dy(xi, y, y_shape) for xi in x])
256
257 if init_targets is not None:
258 assert isinstance(init_targets, (list, tuple))
259 for init in init_targets:
260 init.run()
261 if x_init_value is None:
262 x_init_value = [None] * len(x)
263 # pylint: disable=g-complex-comprehension
264 ret = [_compute_gradient(xi, x_shapei, dxi, y, y_shape, dyi, x_init_valuei,
265 delta, extra_feed_dict=extra_feed_dict)
266 for xi, x_shapei, dxi, dyi, x_init_valuei in zip(x, x_shape, dx, dy,
267 x_init_value)]
268 return ret
269
270
271@tf_export(v1=["test.compute_gradient"])

Callers 1

compute_gradientFunction · 0.70

Calls 3

_compute_dx_and_dyFunction · 0.85
_compute_gradientFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected