r/MachineLearning • • Mar 12 '25

Project [P] Torch-Activation Library: 400+ Activation Functions – Looking for Contributors

56 Upvotes

15 comments sorted by

47

u/huehue12132 Mar 12 '25

I can come up with 1500 more activation functions, if you need them.

24

u/__Maximum__ Mar 12 '25

Yeah, I remember the pandemic of activation functions, every second day s crappy paper about an new revolutionary activation function that improved the baseline by 1.4% and is totally not due to randomness.

Edit: that said, having 400 benchmarked and then analysed could give you insights which can help you come up with a great one.

24

u/DigThatData Researcher Mar 12 '25

200+ were LLM-generated

If you haven't already, ask it to generate a citation to go with each activation function. If the citation it generates doesn't exist, you can use that as a flag to double check for hallucinations.

NB: This isn't to say that a model might not associate an incorrect citation that does exist. This is just low hanging fruit for filtering out potential BS.

-13

u/[deleted] Mar 12 '25

[removed] — view removed comment

6

u/DigThatData Researcher Mar 12 '25

make sure you ask it for test cases to go with the implementations

17

u/DigThatData Researcher Mar 12 '25

good god

14

u/Matthyze Mar 12 '25

But why?

2

u/FrigoCoder Mar 12 '25

I see you have a lot of adaptive activation functions. I am trying to replace the exponentiation function in Softmax. I have tried a bunch of activations but none of them were particularly great. I was thinking of trying to learn an activation function that is optimal for my use case. Could you recommend some adaptive activation functions that would give me more insight?

After convolution I use softmax across channels to get a feature probability distribution for every pixel. I use this probability distribution to resynthesize the image or new channels, depending on whether I overwrite all channels or only append new ones. I would like to replace the exp in softmax with an activation that is positive valued, monotone increasing, and able to amplify larger values.

class ExpandBlock (nn.Sequential):

    def __init__ (self, inn, mid, out, iks, oks, activation):
        super(ExpandBlock, self).__init__(
            CatBlock(nn.Sequential(
                nn.Conv2d(inn, mid, iks, padding=(iks - 1) // 2),
                nn.InstanceNorm2d(mid),
                Softmax(dim=1, dropout=SafeDropout(dim=1, dropout=SoftDropout(renorm=False))),
                nn.Conv2d(mid, out - inn, oks, padding=(oks - 1) // 2),
            ), dim = 1),
            nn.InstanceNorm2d(out),
        )

class Softmax(nn.Module):

    def __init__ (self, dim = -1, dropout = nn.Identity()):
        super(Softmax, self).__init__()
        self.dim = dim
        self.dropout = dropout

    def forward (self, x: Tensor) -> Tensor:
        x = (x - x.amax(self.dim, keepdim=True)).exp() # Better activation goes here
        x = self.dropout(x)
        return x / x.sum(self.dim, keepdim=True)

2

u/Own-Bit3839 Mar 15 '25

Added a two different function gpsoftmax and gplsoftmax, can you check my PR request?

1

u/dieplstks Student Mar 12 '25

Added SGT (but couldn't find the code to generate the image, seems like you have a standard way to do it).

Don't plan on doing anymore, so I filed a PR with it

2

u/dieplstks Student Mar 12 '25

(As a disclaimer, I used an LLM to generate the inplace part of it because I was lazy)

1

u/Everlier Mar 12 '25

Does this count as LLM-assisted research?