PyTorch - Custom ReLU squared Implementation
I work on a project and I want to implement the ReLU squared activation function (max{0,x^2}). Is it ok to call it like:

# example code
    def forward(self, x):
        s = torch.relu(x**2)
        return s


Or should I implement the activation function on my own? In the second case could you please provide me an example on how to do so?

Thanks a lot!

It doesn't make much sense to compute max(0, x**2) because x**2 &gt;= 0 no matter what.
You probably want to compute max(0, x) ** 2 instead:
s = torch.pow(torch.relu(x), 2)

