美文网首页pythondeeplearning
2020-06-05-tensorflow2-tf.where说

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

作者: logi | 来源:发表于2020-06-08 19:01 被阅读0次

    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

    相关文章

      网友评论

        本文标题:2020-06-05-tensorflow2-tf.where说

        本文链接:https://www.haomeiwen.com/subject/mecazhtx.html