PyTorch | 高阶操作
1. where 函数
torch.where(condition, x, y)
: c o n d i t i o n condition condition 是条件, x x x 和 y y y 是同 s h a p e shape shape 的矩阵,针对 x x x 矩阵中的每个元素,如果满足 c o n d i t i o n condition condition 条件就保留元素,不满足 c o n d i t i o n condition condition 条件就使用 y y y 矩阵对应位置的元素值进行替换,最后返回结果。
2. gather 函数
torch.gather(input, dim, index, out=None)
:https://blog.csdn.net/m0_52650517/article/details/119389655#t7