# Google SEO and Structured Data

If you search some specific words like “Apple pie”, Google will show some different results at the first several lines, like this:

You can find out these results contain some extra contents, like rating, votes, time, and cal, Google must know these results are recipes. But how can they know? Using some deep learning algorithm? No, this is all about structured data.

Google support a lot of structured data.

1. Format is Microdata
2. Google support a lot type of structured data of enhancements, like Breadcrumbs, Corporate Contacts, Galleries and Lists, Logos, Sitelinks Searchbox, Site Name, Social Profile Links, and a lot of content types, Articles, Books, Courses, Datasets, Events, Fact Check, Local Businesses, Music, Podcasts, Products, Recipes, Reviews, TV and Movies, Videos. you can find details at Search Gallery.
3. Want to know how to use it, you can see Introduction to Structured Data.

# [TIL] Integration by parts

Integration by parts or partial integration is a theorem to help us solve complex Integration problem of a product of functions. If a function can represent as a product of a function $$u(x)$$ and a derivative of a function $$u′(x)$$ , we can use integration by parts.

If $$u = u(x)$$ and $$du = u′(x) dx$$, while $$v = v(x)$$ and $$dv = v′(x) dx$$, then integration by parts states that:

$$\int_a^b u(x) v'(x) \, dx\ = [u(x) v(x)]_a^b-\int_a^b v(x) u'(x) \, dx$$.

or more compactly:

$$\int u\,dv=uv-\int v\,du$$.

This method is very useful when sometimes integration of $$v(x)u′(x)$$ is easier to find.

# [TIL] Rationalizing Substitution

Rationalizing Substitution is a special type of U-Substitution, radicals in function often cause problems when integrating, use rationalizing substitution we can transform the problem to help us solve them.

For example, sometimes our function contain something like $$\sqrt{x}$$, in order to eliminate the “square root”, we can make substitution $$x = z^2$$，$$dx = 2z dz$$. Then you may can solve function’s integration easier.

# U-Substitution

Today I learned U-Substitution, it is a method for finding integrals in calculus, also known as integration by substitution. Using the fundamental theorem of calculus often requires finding an antiderivative. For this and other reasons, U-Substitution is an important tool in mathematics. It is the counterpart to the chain rule of differentiation.

If you find difficult to finding an antiderivative directly, sometimes you may want use substitution $$u = ϕ(x)$$, rewrite $$f(x)dx$$ form to some function $$g(u)du$$ form and get antiderivative of $$g(u)du$$ first, and put $$x$$ in the antiderivative to get what you want at first.

For example, consider the integral

$$\int _{0}^{2}x\cos(x^{2}+1)\,dx$$

If we apply the formula from right to left and make the substitution $$u = ϕ(x) = (x2 + 1)$$, we obtain $$du = 2x dx$$ and hence; $$x dx = ½du$$

{\begin{aligned}\int _{x=0}^{x=2}x\cos(x^{2}+1)\,dx&{}={\frac {1}{2}}\int _{u=1}^{u=5}\cos(u)\,du {}={\frac {1}{2}}(\sin(5)-\sin(1)).\end{aligned}}

Deep learning researchers always think training is the core problem. Because they always lack funds to purchase the quickest machines. But Google doesn’t worry this, they just have tons of powerful machines, find resources to train a good model isn’t very hard for Google.

Win some deep learning contests isn’t the goal of Google, it is just their PR tricks. Google want to provide AI cloud services. So they kept releasing their well-trained models, Inception-v3, Word2vec, etc. Most of the customers will use API from Google’s well-trained models, like Cloud Natural Language API, Cloud Speech API, Cloud Translation API, Cloud Vision API, Cloud Video Intelligence API. Some of them will want to use models that provide by Google or other companies, or just do some fine tune. And only a little of them will want to train their model all from the beginning.

So, Google cares about service more than training, so they build TPU to speed up service, to reduce service latency.

# Programming languages I ever learned.

I learn a lot of them:

1. Basic – high school
2. pascal – high school
3. C – high school
4. C++ – college
5. VisualBasic – college
6. ASP – college
7. Delphi – college
8. BCB – college
9. VC – college
10. PHP – college
11. Flash – college
12. VHDL – at wok
13. Python – at wok
14. Java – at wok
15. Matlab – at wok
16. Objective-C – at wok
17. Swift – at wok

Maybe I missed something , I am an old man now. 🙂

# How to install Theano on Mac OS X EI Capitan with OpenCL support

I have two Mac, a Mac pro and Macbook pro. They both use AMD display card, so I can’t use CUDA speed up machine learning, so I want to use OpenCL.

First install some requirements:

Then make install environment ( use virtualenv can make everything easy ):

Install Theano:

Then you can use this demo code ( test.py ) to test your Theano:

This test will show something like this:

It just do some math 1000 time, took 1.492254 seconds, and use cpu.

Then we must install libgpuarray to make Theano support OpenCL:

Then we can use THEANO_FLAGS to set use OpenCL device.

Use OpenCL & Cpu in my Mac pro:

Note: Code showed “Used the gnu”, but as you can see, this was using CPU.

Use OpenCL & GPU 1 in My Mac pro:

Finally, we can use OpenCL and GPU.

Performance:

My Mac pro

My Macbook pro

Note: Now we can use Theano and OpenCL. But I was very sad, when I found out Theano is using CUNN, so when you use Theano to do Neural Network, we still need CUDA support. Just for now I don’t know how to solve this problem.

# Before you install Tensorflow on your Mac or your AWS, you must know !!

Recently I started playing Tensorflow on my mac, it very fun. But I found there are some traps about Tensorflow on Mac and AWS, so tell you know.

1. Tensorflow is very slow.
2. Now Tensorflow doesn’t support CUDA on Mac officially, but you can easy find a way to compile it to support CUDA. But almost all new Mac don’t contain a NVIDIA display card, so you still can’t use CUDA. OpenCL support is on the way, open to contributions, but how knows.
3. The HPC of AWS ( g2.2xlarge
and g2.8xlarge ) contain NVIDIA display card, but the card is blow the requirement of default CUDA setting of Tensorflow, so you can’t user precompiled Tensorflow, you need compile it by yourself, and set compute capability is 3.0. And there is a AMI (Amazon Linux x64 AMI with TensorFlow (GPU)), already include Tensorflow on AWA’ AMI market, but this AMI is using precompiled Tensorflow, so it is useless, you can’t use the GPU. And even after your compile and install you own Tensorflow, there is a bug of NVIDIA display driver card, you must update NVIDIA display card driver, and finally you can use GPU from the HPC.