torch.where(condition: Tensor, input, other) 根据条件condition取值,condition为True,取input,为False时,取other 示例 import torch torch.manual_seed(0) tensor_ = torch.randn(20).reshape(4, 5) # 将小于0的值赋值为100,其他保持不变</