Deep learning study - logistic classifier #3

Logistic Classifier 

The logistic classifier is similar to equation of the plane.

W is weight vector, X is input vector and y is output vector.
b is bias that to adjust boundary base.

Anyway, this form is context of logistic regression, called logists.

y is result value of vector calculation that is score, that is not probability.
So, to change a probability, use softmax function.

So, we can choose what probability is close to 1.

Softmax example code in python
scores = [3.0, 1.0, 0.2]
import numpy as np
def softmax(x):
    """Compute softmax values for each sets of scores in x."""
    return np.exp(x) / np.sum( np.exp(x), 0 )

result is
[ 0.8360188   0.11314284  0.05083836]

Softmax plot example in python
# Plot softmax curves
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-2.0, 6.0, 0.1)
scores = np.vstack([x, np.ones_like(x), 0.2 * np.ones_like(x)])

plt.plot(x, scores.T, linewidth=2)

plt.plot(x, softmax(scores).T, linewidth=2)

first plot is

second plot is

The second graph is softmax output value.
The value of the blue line is grows, lines of green and red is almost close to zero.

one more things,
What happen if scores are multiplied or divided by 10?
scores2 = np.array([3.0, 1.0, 0.2])
print( softmax( scores2 * 10))
print( softmax( scores2 / 10))

[ 9.99999998e-01 2.06115362e-09 6.91440009e-13]
[ 0.38842275 0.31801365 0.2935636 ]

If multiplied by the growing differences
If divided, the smaller the difference.

We can take advantage of these properties.
We'll want our classifier to not be too sure of itself in the beginning. -> divided
And then over time, it will gain confidence as it learns. -> multiply


Popular posts from this blog

(OpenCV Study) Background subtractor MOG, MOG2, GMG example source code (BackgroundSubtractorMOG, BackgroundSubtractorMOG2, BackgroundSubtractorGMG)

OpenCV Stitching example (Stitcher class, Panorama)

Example source code of extract HOG feature from images, save descriptor values to xml file, using opencv (using HOGDescriptor )

Real-time N camera stitching Class.

Optical Flow sample source code using OpenCV

OpenCV Drawing Example, (line, circle, rectangle, ellipse, polyline, fillConvexPoly, putText, drawContours)

Video Stabilization example source code, (using cvFindHomography, cvWarpPerspective functions in openCV)

SICK LMS511 sensor data acquisition interface (source code, C++/MFC)

8 point algorithm (Matlab source code) / The method to get the Fundamental Matrix and the Essential matrix

Image warping (using opencv findHomography, warpPerspective)