Skip to content

Instantly share code, notes, and snippets.

@sbugrov
Created July 5, 2017 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbugrov/c21fde606dd2653ac90234213a05a1e0 to your computer and use it in GitHub Desktop.
Save sbugrov/c21fde606dd2653ac90234213a05a1e0 to your computer and use it in GitHub Desktop.
vector <float> sigmoid_d (const vector <float>& m1) {
/* Returns the value of the sigmoid function derivative f'(x) = f(x)(1 - f(x)),
where f(x) is sigmoid function.
Input: m1, a vector.
Output: x(1 - 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 ] = m1[ i ] * (1 - m1[ i ]);
}
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment