YouTip LogoYouTip

Pytorch Torch Heaviside

# PyTorch torch.heaviside Function * * PyTorch torch Reference Manual](#) `torch.heaviside` is a PyTorch function for calculating the Heaviside step function. It returns 1 when input value is greater than 0, 0.5 when equal to 0, and 0 when less than 0. ### Function Definition torch.heaviside(input, values) * * * ## Example Usage ## Example import torch # Create input tensor input= torch.tensor([-1.0, -0.5,0.0,0.5,1.0]) # Specify return value when input is 0 values = torch.tensor([0.5]) # Calculate Heaviside step function x = torch.heaviside(input, values) print(x) * * PyTorch torch Reference Manual](#)
← Pytorch Torch HstackPytorch Torch Hann_Window β†’