如何计算张量中的正值?

Tbe*_*tin 4 python count tensorflow tensor

如何计算 TENSORFLOW 中张量中正值的数量?

谢谢你的帮助。

ben*_*che 6

res = tf.count_nonzero(tf.greater_equal(x, 0.))
                       # or using tf.greater() if you want to exclude 0.
Run Code Online (Sandbox Code Playgroud)

例子:

res = tf.count_nonzero(tf.greater_equal(x, 0.))
                       # or using tf.greater() if you want to exclude 0.
Run Code Online (Sandbox Code Playgroud)