pythondeeplearning

2020-06-05-tensorflow2-tf.where说

2020-06-08  本文已影响0人  logi

API文档:https://www.tensorflow.org/api_docs/python/tf/where?hl=en

用途

tf.where 通过boolean矩阵的true or false 对候选条件下的两个矩阵进行element选取

tf.where will choose an output shape from the shapes of condition, x, and y that all three shapes are broadcastable to.

The condition tensor acts as a mask that chooses whether the corresponding element / row in the output should be taken from x (if the elemment in condition is True) ory` (if it is false).

例子

这里true就选x中的元素,false就选y中的元素

tf.where([[True, False], [False, True]], x=[[1,2],[3,4]] , y=[[5,6],[7,8]] )
image.png
上一篇 下一篇

猜你喜欢

热点阅读