Corrected compute_gradient docstring
authorFergal Cotter <fbcotter90@gmail.com>
Tue, 22 May 2018 18:44:57 +0000 (19:44 +0100)
committerFergal Cotter <fbcotter90@gmail.com>
Tue, 22 May 2018 18:44:57 +0000 (19:44 +0100)
After testing the tf.test.compute_gradient function with complex inputs,
noticed that the docstring specifies that the real/imag partial derivatives
are in the four corners of a larger matrix, when the result given indicates
they are instead interleaved.

tensorflow/python/ops/gradient_checker.py

index 12afcd0..94c8d79 100644 (file)
@@ -283,10 +283,10 @@ def compute_gradient(x,
   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
 
-      J[:m, :n] = d(Re y)/d(Re x)
-      J[:m, n:] = d(Im y)/d(Re x)
-      J[m:, :n] = d(Re y)/d(Im x)
-      J[m:, n:] = d(Im y)/d(Im x)
+      J[::2, ::2] = d(Re y)/d(Re x)
+      J[::2, 1::2] = d(Im y)/d(Re x)
+      J[1::2, ::2] = d(Re y)/d(Im x)
+      J[1::2, 1::2] = d(Im y)/d(Im x)
 
   Args:
     x: a tensor or list of tensors