tf.where 用法
生活随笔
收集整理的这篇文章主要介绍了
tf.where 用法
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
tf.where 应用到了张量的广播机制 张量的广播机制
tf.where(condition, x=None, y=None, name=None )[if condition[k] =True 取 x[k] else 取 y[k]]
import tensorflow as tf c=tf.where([True, False, False, True], [1,2,3,4], [100,200,300,400]) print(c)c=tf.where([True, False, False, True], [1,2,3,4], [100]) print(c)c=tf.where([True, False, False, True], [1,2,3,4], 100) print(c)c=tf.where([True, False, False, True], 1, 100) print(c) tf.Tensor([ 1 200 300 4], shape=(4,), dtype=int32) tf.Tensor([ 1 100 100 4], shape=(4,), dtype=int32) tf.Tensor([ 1 100 100 4], shape=(4,), dtype=int32) tf.Tensor([ 1 100 100 1], shape=(4,), dtype=int32)总结
以上是生活随笔为你收集整理的tf.where 用法的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: yolo loss 将图像标注的真实事坐
- 下一篇: tf.broadcast_dynamic