Computes the theoretical and numeric Jacobian of f.
tf.test.compute_gradient(
f, x, delta=0.001
)
With y = f(x), computes the theoretical and numeric Jacobian dy/dx.
Args
f
the function.
x
the arguments for the function as a list or tuple of values convertible
to a Tensor.
delta
(optional) perturbation used to compute numeric Jacobian.
Returns
A pair of lists, where the first is a list of 2-d numpy arrays representing
the theoretical Jacobians for each argument, and the second list is the
numerical ones. Each 2-d array has "y_size" rows
and "x_size" columns where "x_size" is the number of elements in the
corresponding argument and "y_size" is the number of elements in f(x).