Tensorflow gradients: without automatic implicit sum
<p>In tensorflow, if one has two tensors <code>x</code> and <code>y</code> and one want to have the gradients of <code>y</code> with respect to <code>x</code> using <code>tf.gradients(y,x)</code>. Then what one actually gets is :</p>

<pre><code>gradient[n,m] = sum_ij d y[i,j]/ d x[n,m]
</code></pre>

<p>There is a sum over the indices of y, is there a way to avoid this implicit sum? To get the whole gradient tensor <code>gradient[i,j,n,m]</code>?</p>

<p>There isn't a way. TensorFlow 0.11 <code>tf.gradients</code> implements standard reverse-mode AD which gives the derivative of a scalar quantity. You'd need to call <code>tf.gradients</code> for each <code>y[i,j]</code> separately</p>

python tensorflow gradients