Count number of "True" values in boolean Tensor
<p>I understand that <code>tf.where</code> will return the locations of <code>True</code> values, so that I could use the result's <code>shape[0]</code> to get the number of <code>True</code>s. </p>

<p>However, when I try and use this, the dimension is unknown (which makes sense as it needs to be computed at runtime). So my question is, how can I access a dimension and use it in an operation like a sum?</p>

<p>For example:</p>

<pre><code>myOtherTensor = tf.constant([[True, True], [False, True]])
myTensor = tf.where(myOtherTensor)
myTensor.get_shape() #=&gt; [None, 2]
sum = 0
sum += myTensor.get_shape().as_list()[0] # Well defined at runtime but considered None until then.
</code></pre>