梯度为0

1
2
out[out > 0] = 1
out[out <= 0] = -1

As your function’s derivative is 0 everywhere (except for the input 0, where it isn’t smooth), you can also implement it as a function:

请作者喝一杯咖啡☕️