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

Function compute_gradient_error

tensorflow/python/ops/gradient_checker.py:354–395  ·  view source on GitHub ↗

Computes the gradient error. Computes the maximum error for dy/dx between the computed Jacobian and the numerically estimated Jacobian. This function will modify the tensors passed in as it adds more operations and hence changing the consumers of the operations of the input tensors. Thi

(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

352 "support for functions. Note that the two versions have different usage, "
353 "so code change is needed.")
354def compute_gradient_error(x,
355 x_shape,
356 y,
357 y_shape,
358 x_init_value=None,
359 delta=1e-3,
360 init_targets=None,
361 extra_feed_dict=None):
362 """Computes the gradient error.
363
364 Computes the maximum error for dy/dx between the computed Jacobian and the
365 numerically estimated Jacobian.
366
367 This function will modify the tensors passed in as it adds more operations
368 and hence changing the consumers of the operations of the input tensors.
369
370 This function adds operations to the current session. To compute the error
371 using a particular device, such as a GPU, use the standard methods for
372 setting a device (e.g. using with sess.graph.device() or setting a device
373 function in the session constructor).
374
375 Args:
376 x: a tensor or list of tensors
377 x_shape: the dimensions of x as a tuple or an array of ints. If x is a list,
378 then this is the list of shapes.
379 y: a tensor
380 y_shape: the dimensions of y as a tuple or an array of ints.
381 x_init_value: (optional) a numpy array of the same shape as "x"
382 representing the initial value of x. If x is a list, this should be a list
383 of numpy arrays. If this is none, the function will pick a random tensor
384 as the initial value.
385 delta: (optional) the amount of perturbation.
386 init_targets: list of targets to run to initialize model params.
387 extra_feed_dict: dict that allows fixing specified tensor values
388 during the Jacobian calculation.
389
390 Returns:
391 The maximum error in between the two Jacobians.
392 """
393 grad = compute_gradient(x, x_shape, y, y_shape, x_init_value, delta,
394 init_targets, extra_feed_dict=extra_feed_dict)
395 return _compute_error(grad)

Callers

nothing calls this directly

Calls 2

_compute_errorFunction · 0.85
compute_gradientFunction · 0.70

Tested by

no test coverage detected