Function of Activation functions
is it possible to define a function of activation function? I tried to do :
def activation():
    # return nn.Sin()
    # return nn.Tanh()
    # return nn.Sigmoid()
    # return nn.Tanhshrink()
    return nn.HardTanh(-1,1)
    # return nn.Hardswish()
    # return nn.functionnal.silu()

But i get an error when trying to call it. Here is an example:
def f():
  return nn.Tanh()
input = torch.randn(2)
output = f(input)
print(output)

it outputs &quot;TypeError: f() takes 0 positional arguments but 1 was given&quot;. It doesn't work even i gave it an argument x.

You can either use the object-oriented approach:
&gt;&gt;&gt; f = nn.Tanh()
&gt;&gt;&gt; output = f(x)

Or the functional approach where you will find the equivalent for nn.Tanh inside nn.functional as tanh.
&gt;&gt;&gt; f = nn.functional.tanh
&gt;&gt;&gt; output = f(x)

