2016年11月7日 星期一

Taiwan ancient buildings recognition by Convolution Neural Network

Overview

       The Alex net is applied to recognize 4 different types of Taiwan ancient buildings in this article.

Motivation

      I'm new to Deep Learning, so I want to do some exercise to warm up.  And since it would be interesting and meaningful to combine the technology together with the culture, I apply the Alex net to recognize 4 different types of Taiwan ancient buildings.

Introduction

     The ancient buildings in Taiwan can be categorized into 4 types:

1. The traditional Chinese buildings:  Many of Taiwanese are successors of the immigration who emigrated from China about hundred years ago.  Therefore, many old buildings are ancient Chinese buildings.  The following figure shows the traditional residence.


2. The traditional Japanese buildings:  Taiwan has been colonial ruled by Japan for about half of the century. Therefore, there're many traditional Japanese buildings left.  The following figure shows the Japanese temple located in Taoyuan.

3. The baroque style buildings:  During the Japanese colonial period, several government buildings are designed as the Japanese Baroque style.  These buildings are popular in Japan during the Meiji period. Thus, this category is labeled as Japanese modern in the present work.  The most famous building of this style might be the Presidential Palace of Taiwan, as shown follows.

4. The modern Taiwan buildings:  The word "modern" here refers to those buildings that constructed during the Early Revival Period.  I'm not quite a fan of these kinds of buildings.  However, these buildings still in everyone's childhood memory.  Thus, these buildings are also recognized by the network.




Data Sets

       The collection of data is very time-consuming. And since there are only countable historic buildings in Taiwan as well as not every building in these kinds are posted to the internet, I suddenly ran out of data to train the net.  Therefore, some of the buildings in Chinese and Japanese are also collected.
       After all, I spend a whole data to collect all of the following data!  However, the training set seems too few to train an Alex net, though...
      The collected data are listed below (25% of these data are used to calculate the validation):
Traditional Chinese Buildings: 159
Traditional Japanese Buildings: 152
Modern Japanese Buildings: 169
Modern Taiwan Buildings: 119


Result

       The training result is shown as follows.  After 30 epoch, the final accuracy (validation set) is 66%.
Several results in the test set are shown below:


       Although the training data are quite insufficient, the result seems acceptable: up to 2/3 buildings are classified correctly.  And it might get better performance if more and more data are included.  Also, the Alex net seems to be capable of solving problems like this.  Therefore, it's more reasonable to collect more data than design more complex neural network if one want to improve the predictions.



2016年11月2日 星期三

Nemiver - A wonderful tool for tracing code and debug in Linux

Overview

    This article will introduce a package that can facilitate tracing code and debug in Linux.

Motivation

    In my opinion, to see how the program run is the best way to understand its implementation.  Therefore, I often use debugger to explore a program at the first time.  By using the debugger, you can not only see which code block is actually accessed by a process but also save a lot of time to include all header and source files (as you might do for code editors) since all you need is feed the debugger with the binary program.
    However, the traditional tools in Linux (such as gdb or DDD) are not user-friendly, such as not display the code as colorful texts as well as the texts size can't be adjusted, as shown follows.  In the next section, I'll introduce a new tool that can remedy these drawbacks.

Nemiver   

     Nemiver is a Debugger that I have found recently.  As shown below, it not only display the code gracefully, but also be able to change the text size and editor theme.  The following code is about to perform Merge Sort to std::list.  As you can see, the lower half panel display the value of each local variables and even each elements of the std::list.  Furthermore, if the process is in the member function of a certain class, you can also see the data member displayed.

Trouble Shooting

    Sometimes you might encounter the following situation (a window pop out and says "Cannot find file '/build/.../linux/raise.c'..."), it might due to an exception thrown by your code or the process fail to pass a certain assert statement.

You can click the "Target Terminal" tab in the bottom of panel to get more information.