Thursday, 28 February 2019

Softmax Intuition

Given a classification model, the output will produce the confidence score for each class instead of the original value of forward propagation.

For example, model predict a = -10, b = 10, c = 1.
Softmax will convert the output to confidence score as following.
a1 = e^a / (e^a + e^b + e^c)
b1 = e^b / (e^a + e^b + e^c)
c1 = e^c / (e^a + e^b + e^c)

As a result, the model will produce the confidence score of class a, b, c as a1, b1, c1.


[image source: https://cdn-images-1.medium.com/max/2000/1*eqQuFgXPUP5L6J_vVH19wg.png]




Wednesday, 27 February 2019

Protobuf Error @@


This error often happen when building opencv or caffe.
I found it is quite annoying as everytime I have to spend a lot of time to debug.
I think I understand the issue now.

First, check the protoc version you are using:-
$ protoc --version
libprotoc 2.6.1
$ dpkg -l | grep protobuf

 
Second, check which protoc you are using, remove those not from /usr/bin/:-
$ which protoc
/home/user/.conda/envs/caffe2/bin/protoc
$ conda uninstall libprotobuf



Third, remove and install again the protoc and protobuf:-

$ sudo add-apt-repository ppa:maarten-fonville/protobuf 
$ sudo apt-get update
$ sudo apt-get remove libprotobuf-dev libprotoc-dev protobuf-compiler
$ sudo apt-get install libprotobuf-dev libprotoc-dev protobuf-compiler
 
Finally rerun the make for opencv and caffe.
One thing to take note for opencv as there are some conflict when enabling the dnn module.
If there is an error of protobuf when building opencv, try add on the following to cmake:-
-DBUILD_PROTOBUF=OFF
-DPROTOBUF_UPDATE_FILES=ON
-DBUILD_OPENCV_DNN=OFF

platform: ubuntu16.04, python2.7, anaconda3

Intuition

Most of the time, I will write down all the coding experience or error in a small book.
However, I found that it is difficult to organize and to track.
Sometime, I will write some rubbish on my notebook, it makes the things worse.
I used to write the blog long time ago, but I stop for quite a long time.
I decided to get back to blog and write down my experience.
You know, time flies, age is getting older, memory is getting lousy.
So, let's get started!