torch.where(condition, input, other)返回 i n p u t input input或是 o t h e r other other中满足 c o n d t i o n condtion condtion的元素。
该操作定义为:
out i = { input i if condition i other i otherwise \text{out}_i = \begin{cases} \text{input}_i & \text{if } \text{condition}_i \\ \text{other}_i & \text{otherwise} \end{cases} outi={inputiotheriif conditioniotherwise
注意:属性
c
o
n
d
i
t
i
o
n
condition
condition,
i
n
p
u
t
input
input,
o
t
h
e
r
other
other必须是:ref:broadcast <broadcasting-semantics>
。