1.第一种用法:tf.where(input, name=None):返回输入矩阵中true的位置
For example:
(1)‘input’ tensor is [[True, False]
[True, False]]
input里面有两个true,所以返回两行(两个位置信息)
where(input) ==> [[0, 0],
[1, 0]]

(2)input tensor is [[[True, False]
[True, False]]
[[False, True]
[False, True]]
[[False, False]
[False, True]]]
里面有5个true,所以返回5个位置信息。
第一位是0,1,2号矩阵,第二三位是在每个矩阵中的位置信息
where(input) ==> [[0, 0, 0],
[0, 1, 0],
[1, 0, 1],
[1, 1, 1],
[2, 1, 1]]
2.第二种用法:tf.where(input, a,b),其中a,b均为尺寸一致的tensor,作用是将a中对应input中true的位置的元素值不变,其余元素进行替换,替换成b中对应位置的元素值。
for example:
tensorflow函数_tf.where()

相关文章:

  • 2022-01-21
  • 2021-12-29
  • 2021-04-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-15
  • 2021-11-29
  • 2021-07-16
  • 2021-09-02
  • 2021-07-23
相关资源
相似解决方案