Pytorch tensor特定条件判断索引

torch.where() 用于将两个broadcastable的tensor组合成新的tensor,类似于c++中的三元操作符“?:” 区别于python numpy中的where()直接可以找到特定条件元素的index 想要实现numpy中where()的功能,可以借助nonzero() 对应numpy中的where()操作效果:
相关文章
相关标签/搜索