How to Compile Torch-Android with OpenBLAS Support

This post aims to provide a practical guidance to how to compile Torch-Android deep learning tool with OpenBLAS support. All the procedure is target for UNIX-like environment.
I presume that you know what BLAS or OpenBLAS is, if you don’t click the blue word to find out.

Prepare Source Code

You can find OpenBLAS on Github OpenBLAS’s repo..
Get the source code by Git.

1
git clone https://github.com/xianyi/OpenBLAS.git

How to Use NDK to Build A shared Android Native Library

This post aims at providing a brief guide on using NDK (Native Development Kit) to build a shared library for an Android application.
Be noted that this post will not teach you how to develop a whole JNI supported Android application, the outcome of the following procedure will only lead you to generate a shared library (*.so file) which you can use for your android application.
And if you want to really use this generated library, you will have to change some function formats according to your project, modification part will be covered of course.

Download Essentials

Android NDK is a must.

Set Up NDK Environment

As we need to use ndk-build command to build the C/C++ code for Android applications running under the ARM architecture. First we need to let the system to know where to find ndk-build.
Open a terminal and type as follows (noted that you need you change the ndk path according to your download and location):

1
2
cd # Guarantee that you are under the "/Home" directory, works for Ubuntu at least, for other systems "cd /Home" may work.
vim .bashrc # Or use command "gedit .bashrc" if you are not a vimer.

A Quick GDB Tutorial

This post will help you to go throw the GDB debugger quickly. You are to start a C project from scratch under Linux (I’m using Ubuntu 15.10 distribution).
If you can find this post, I presume that you have the basic knowledge on what GDB is.


GNU GDB

Neural Style -- A Computer Artist

This post is an introduction to neural style program. Neural style is a CNN based algorithm to apply an image’s style to another image, this it the most interesting program which is related to deep learning I ever found. The source code is published on the Github, Torch7 version and tensorflow version.
The related papers are A Neural Algorithm of Artistic Style published on Sep. 2015, Image Style Transfer Using Convolutional Neural Networks published on 2016, and for videos Artistic style transfer for videos, published on Apr. 2016.
Allow me to show you some pictures here:


Artistic Style Shift from Von Gogh to Monet

Source first two images comes from the Internet, click on the The Summer, Poppy Field and the The Starry Night to view the original image.

A Note to Techniques in Convolutional Neural Networks and Their Influences III (paper summary)

Since we have already got some bases on how CNN works, so this post I prefer to focus more on the ideologies that make these architectures unique and the general technics that can improve the performance of the CNN. If you are new to this, please visit my previous post, I believe it can help you to understand the paper or at least get the key point of the paper.

ZFNet

Related paper is:Visualizing and Understanding Convolutional Networks, published on Nov. 2013.

Step by Step, A Tutorial on How to Feed Your Own Image Data to Tensorflow

This blog aims to teach you how to use your own data to train a convolutional neural network for image recognition in tensorflow. The focus will be given to how to feed your own data to the network instead of how to design the network architecture.
Before I started to survey tensorflow, me and my colleagues were using Torch7 or caffe. They both are very good machine learning tools for neural network. The original propose for turning to tensorflow is that we believe tensorflow will have a better support on mobile side, as we all know that Android) and tensorflow are both dominated by Google.
If you are really hurry with importing data to your program, visit my Github repo. to get the necessary code to generate, load and read data through tfrecords. I’m too busy to update the blog. Just clone the project and run the build_image_data.py and read_tfrecord_data.py.

Normalizations in Neural Networks

Normalizations for the input data (normalization, equalization)

In image process area, the term “normalization)” has many other names such as contrast stretching, histogram stretching or dynamic range expansion etc.
If you have an 8-bit grayscale image, the minimum and maximum pixel values are 50 and 180, we can normalize this image to a larger dynamic range say 0 to 255. After normalize, the previous 50 becomes 0, and 180 becomes 255, the values in the middle will be scaled according to the following formula:


(I_n: new_intensity) = ((I_o: old_intensity)- (I_o_min: old_minimum_intensity)) x ((I_n_max: new_maximum_intensity) - (I_n_min: new_minimum_intensity)) / ((I_o_max: old_maximum_intensity) - (I_o_min: old_minimum_intensity)) + (I_n_min: new_minimum_intensity)


Normalization