Re: Add softplus implementation in scipy.special
Warren Weckesser <[email protected]>
| Newsgroups | gmane.comp.python.scientific.devel |
|---|---|
| Message-ID | <CAGzF1uco+h8e=4UR8jYP7Er5rrG3LNALqhraShzsJVXhX-44Ow@mail.gmail.com> |
On 4/13/23, Robert Kern <[email protected]> wrote: > +1 on adding `softplus()`. > > I would not worry about reading StackOverflow in this case. Our general > rule of thumb is that the minimum copyrightable segment of code is about 10 > lines. Everything about softplus is smaller than that. And we would not be > copying the code straight in, in any case. We'll want a ufunc, I think. > For anyone reading the mailing list but not following the github issue: I added a comment (https://github.com/scipy/scipy/issues/17905#issuecomment-1507247170) that shows a simple option for computing `log1pexp(x)` (aka `softmax(x)`): use `np.logaddexp(0, x)`. Warren > On Thu, Apr 13, 2023 at 5:17 AM Pamphile Roy <[email protected]> > wrote: > >> Hi Aadya, >> >> Thank you for sending the email. This is in reference to the issue: >> https://github.com/scipy/scipy/issues/17905 >> >> Note that we cannot use code from StackOverflow due to licensing >> incompatibilities. See here for more details >> https://scipy.github.io/devdocs/dev/hacking.html#license-considerations >> >> Cheers, >> Pamphile >> >> >> On 13.04.2023, at 10:28, [email protected] wrote: >> >> Hello Everyone, >> It might be nice to have a numerically stable softplus implementation, ie >> np.log1p(np.exp(x)) >> >> This implementation can be based on the following stackoverflow answers : >> >> https://cs.stackexchange.com/questions/110798/numerically-stable-log1pexp-calculation >> >> https://stackoverflow.com/questions/44230635/avoid-overflow-with-softplus-function-in-python >> >> It can have a good place in the scipy module as it has other applications >> apart from ML/AI like it's a quite natural penalty function in >> optimization >> if one desires a smooth penalty in some optimization problems. >> >> All opinions are welcome. Let's discuss this? >> _______________________________________________ >> SciPy-Dev mailing list -- [email protected] >> To unsubscribe send an email to [email protected] >> https://mail.python.org/mailman3/lists/scipy-dev.python.org/ >> Member address: [email protected] >> >> >> _______________________________________________ >> SciPy-Dev mailing list -- [email protected] >> To unsubscribe send an email to [email protected] >> https://mail.python.org/mailman3/lists/scipy-dev.python.org/ >> Member address: [email protected] >> > > > -- > Robert Kern > _______________________________________________ SciPy-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/scipy-dev.python.org/ Member address: [email protected]