1. torch.clamp(tensor, min, max): 将tensor压缩到[min, max] tmp_input = torch.randint(1, 125, (10,1)) tmp_output = torch.clamp(tmp_input, 50, 100) print(tmp_input) print(tmp_output) 来源:oschina链接:https://my.oschina.net/EJaven/blog/4491145 标签 torch pytorch