Skip to content

Instantly share code, notes, and snippets.

@justindmartin
Last active February 8, 2019 18:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justindmartin/5856162 to your computer and use it in GitHub Desktop.
Save justindmartin/5856162 to your computer and use it in GitHub Desktop.
This is a sigmoid function in PHP.
<?php
function sigmoid($t){
return 1 / (1 + pow(M_EULER, -$t));
}
?>
@mickrip
Copy link

mickrip commented Jun 27, 2013

I happened to google this looking to use a signoid curve. I found yours didn't work, but this did.

<?php
function sigmoid($t){
    return 1 / (1 + exp(-$t));
}
?>

@digitalgrease
Copy link

The problem with it is M_EULER should be M_E.

@raymondjplante
Copy link

Both work (with M_E, that is). Anyone happen to have softmax PHP function handy?

@raymondjplante
Copy link

Wrote a basic softmax in case anyone's interested: https://gist.github.com/raymondjplante/d826df05349c1d4350e0aa2d7ca01da4

@ai-a
Copy link

ai-a commented Feb 8, 2019

Thanks a million! was looking for this function! so simple!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment