Piecewise Activation Function
I'm trying to write a piecewise activation function whose slope between -6 and 0 is 0.1 and the other places are one.
And the input(X) size is (B, C, H, W).
So I concluded that the best way is the simple line code:
 x[-6&lt;x and x&lt;0] = x[-6&lt;x and x&lt;0] * 0.1

But I face this error:
RuntimeError: bool value of Tensor with more than one value is ambiguous

Is there any solution for solving this error?

The most simple version of what you need is:
import torch

def custom_activ(input):
    return torch.where((input&gt;-6) &amp; (input&lt;0.) , 0.1*input, input)

