Imran's personal blog

February 14, 2016

Notes on Sigmoid functions.

Filed under: Uncategorized — ipeerbhai @ 2:24 am

This is a quick list of functions for computing regularized logistic regressions:

The logistic equation in matlab format is:

h = 1 / (1 + exp(-x))) %  In the case where x is a vector or matrix, you’ll want to use an index loop for rows and columns, and compute for the entire vector or Array and assign to a return vector/array.

This creates a cost function that looks like this:

and gradients that look like this:

sigX = sigmoid(X*theta); % this is a vector of sigmoid values, as theta is a vector.

grad(gradCtr) = 1/m * ((sigX-y)’ * X(:,gradCtr)) + lambda/m*theta(gradCtr); % remember sigX is a vector of values where each element is between 0 and 1, and y is a label vector with elements exclusively 0 or 1.

Here, gradCtr is a loop iterator from 2 to the end of the theta array.  You car arrive at the above by taking the derivate of the cost function and simplifying it.


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

%d bloggers like this: