Skip to content

Instantly share code, notes, and snippets.

@sbugrov
Created July 4, 2017 00:08
Show Gist options
  • Save sbugrov/bfac5e49c21e20109b2c090b677b8f71 to your computer and use it in GitHub Desktop.
Save sbugrov/bfac5e49c21e20109b2c090b677b8f71 to your computer and use it in GitHub Desktop.
vector <float> sigmoid (const vector <float>& m1) {
/* Returns the value of the sigmoid function f(x) = 1/(1 + e^-x).
Input: m1, a vector.
Output: 1/(1 + e^-x) for every element of the input matrix m1.
*/
const unsigned long VECTOR_SIZE = m1.size();
vector <float> output (VECTOR_SIZE);
for( unsigned i = 0; i != VECTOR_SIZE; ++i ) {
output[ i ] = 1 / (1 + exp(-m1[ i ]));
}
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment