Tensorflow: how to obtain the diagonals of multiple matrices (batched mode)
<p>I have a tensor which is <code>[100 X 16 X 16]</code>. I want to get the diagonal elements of this tensor to get a tensor of shape <code>[100 X 16]</code>. I tried the following:</p>

<p><code>#sum_cov</code> is <code>[100 X 16 X 16]</code> and <code>diagonal_elements</code> is expected to be <code>[100 X 16]</code>.</p>

<p><code>diagonal_elements = tf.diag_part(sum_cov)</code></p>

<p>But, I get the following error:</p>

<p><code>Input must have even rank &lt;= 6, input rank is 3 for 'DiagPart'</code></p>

<p>Can someone please tell me how to achieve this?</p>