If x or y is complex, the Jacobian will still be real but the
corresponding Jacobian dimension(s) will be twice as large. This is required
even if both input and output is complex since TensorFlow graphs are not
necessarily holomorphic, and may have gradients not expressible as complex
numbers. For example, if x is complex with shape [m] and y is complex
with shape [n], each Jacobian J will have shape [m * 2, n * 2] with
the dimensions of x as a tuple or an array of ints. If x is a list,
then this is the list of shapes.
y
a tensor
y_shape
the dimensions of y as a tuple or an array of ints.
x_init_value
(optional) a numpy array of the same shape as "x"
representing the initial value of x. If x is a list, this should be a list
of numpy arrays. If this is none, the function will pick a random tensor
as the initial value.
delta
(optional) the amount of perturbation.
init_targets
list of targets to run to initialize model params.
extra_feed_dict
dict that allows fixing specified tensor values
during the Jacobian calculation.
Returns
Two 2-d numpy arrays representing the theoretical and numerical
Jacobian for dy/dx. Each has "x_size" rows and "y_size" columns
where "x_size" is the number of elements in x and "y_size" is the
number of elements in y. If x is a list, returns a list of two numpy arrays.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.test.compute_gradient\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/gradient_checker.py#L269-L333) |\n\nComputes and returns the theoretical and numerical Jacobian. (deprecated) \n\n tf.compat.v1.test.compute_gradient(\n x,\n x_shape,\n y,\n y_shape,\n x_init_value=None,\n delta=0.001,\n init_targets=None,\n extra_feed_dict=None\n )\n\n| **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use tf.test.compute_gradient in 2.0, which has better support for functions. Note that the two versions have different usage, so code change is needed.\n\nIf `x` or `y` is complex, the Jacobian will still be real but the\ncorresponding Jacobian dimension(s) will be twice as large. This is required\neven if both input and output is complex since TensorFlow graphs are not\nnecessarily holomorphic, and may have gradients not expressible as complex\nnumbers. For example, if `x` is complex with shape `[m]` and `y` is complex\nwith shape `[n]`, each Jacobian `J` will have shape `[m * 2, n * 2]` with \n\n J[:m, :n] = d(Re y)/d(Re x)\n J[:m, n:] = d(Im y)/d(Re x)\n J[m:, :n] = d(Re y)/d(Im x)\n J[m:, n:] = d(Im y)/d(Im x)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `x` | a tensor or list of tensors |\n| `x_shape` | the dimensions of x as a tuple or an array of ints. If x is a list, then this is the list of shapes. |\n| `y` | a tensor |\n| `y_shape` | the dimensions of y as a tuple or an array of ints. |\n| `x_init_value` | (optional) a numpy array of the same shape as \"x\" representing the initial value of x. If x is a list, this should be a list of numpy arrays. If this is none, the function will pick a random tensor as the initial value. |\n| `delta` | (optional) the amount of perturbation. |\n| `init_targets` | list of targets to run to initialize model params. |\n| `extra_feed_dict` | dict that allows fixing specified tensor values during the Jacobian calculation. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| Two 2-d numpy arrays representing the theoretical and numerical Jacobian for dy/dx. Each has \"x_size\" rows and \"y_size\" columns where \"x_size\" is the number of elements in x and \"y_size\" is the number of elements in y. If x is a list, returns a list of two numpy arrays. ||\n\n\u003cbr /\u003e"]]