torch.heaviside¶
- torch.heaviside(input, values, *, out=None) Tensor ¶
计算
input
中每个元素的 Heaviside 阶跃函数。Heaviside 阶跃函数定义为示例
>>> input = torch.tensor([-1.5, 0, 2.0]) >>> values = torch.tensor([0.5]) >>> torch.heaviside(input, values) tensor([0.0000, 0.5000, 1.0000]) >>> values = torch.tensor([1.2, -2.0, 3.5]) >>> torch.heaviside(input, values) tensor([0., -2., 1.])