Silent Joy

I have pondered the Pali terms Piti and Sukha lately. They are the first two constituents of the First Jhana. The Jhanas are states of peace and/or of absorption encountered in Buddhist meditation…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Deep Learning With React Native

Rest assured, that is not going to happen anytime soon! 😛

We hear about AI every day. We hear about AI in our science fiction movies and we also talk to an AI on our phones.

Some might think that Machine Learning and Deep Learning are just new, fancier names for Artificial Intelligence. But this is not the case.

Imagine AI, Machine Learning, and Deep Learning as three concentric circles. The AI circle is the largest as it came first. The Machine Learning circle is a slightly smaller circle, and finally, deep learning is the smallest circle.

Machine Learning (ML) is a sub-field of AI. The reason for it being called Machine Learning is that it deals with —

In short, Machine Learning is a system that learns from examples and experiences.

In ML, we provide a system with data. The system then analyses the data and improves itself to better serve its purpose.

ML is often compared with the human brain since we also learn from our surroundings and experiences and adapt to live more comfortably.

Now, you might come across a few questions in your mind like:

Well, the answer to this can be broken down into the following points

So, it is not the flexibility of brain that helps us learn but the inflexibility. This is one of the basic principles that one needs to follow when building a Machine Learning system. Your system needs to be hardcoded with data that will tell it what kind of patterns it can expect.

Suppose that you have to write a machine learning algorithm that can differentiate between an apple and an orange. The simplest system that can do this would be one that :

This is just an over-simplified description of the system. But in reality, you will start off by writing some rules to differentiate between the fruits. One such rule could be where you tell the system to count the number of orange pixels in the image and compare it with the other dominant pixel.

But what about grayscale images? Or images with no apples or oranges at all? The fact is that for every set of rules that you write, there will be at least one image where they won’t work!

So we clearly need a better algorithm that can figure out those rules for us. What we need is Classifier. A classifier is a function that takes data an input and assigns a label to it at the output.

There are 2 kinds of data that you’ll have to deal with.

The output of the classifier will look something like this:

Here the first 2 columns are the measurements that you will use to define. These are called Features. The third column is the Label. Here the label tells us which kind of fruit the does the features represent. Each row is called an Example.

The act of extracting useful features from a dataset is called Feature Engineering. This kind of dataset may be useful for stock market analysis but it doesn’t help us differentiate between various fruits.

We needed something better. We needed Deep Learning!

Deep Learning is a part of Machine Learning itself. It deals with algorithms that are inspired by the structure and function of the brain.

Deep Learning has led to great results in the field of Machine Learning and Computer Vision.

The major advantage of Deep Learning is that it does not need feature engineering. We can use the raw pixels from the image as the features. This is mainly possible because the classifier used in Deep Learning is a neural network.

Neural networks can learn complex functions. Under the hood, Deep Learning uses multiple layers of neurons.

Creating a neural network from scratch is not that easy. TensorFlow has proved to be extremely helpful in doing this for us.

One of the most important features of TensorFlow is that we can save the trained model as a binary file.

The reason why TensorFlow is good at creating neural networks is that it doesn’t actually create a neural network from scratch. Instead, it retrains an existing classifier called Inception.

An average image classifier is trained on around 1000–2000 images. Inception was trained over 1.2 million that range over 1000 categories. This was done over the duration of 2 weeks on a desktop with 8 GPUs.

Retraining inception (transfer learning) has several advantages:

React-Native TensorFlow is an open source library for React Native.

It provides us with 2 APIs

Using the image recognition API is super easy. All you need to do is these 5 steps:

Here, pb is the extension of the output model file and txt is the extension for the label file.

2. Add TensorFlow model file to assets:

3. Add the label file as to the assets:

4. Initialize tfImageRecognition API class using the model and the label:

5. Call recognize function with the image to recognize:

Finally, here’s what we get:

react-native-caffe2 is another great open-source library that brings deep learning to the mobile platform. The main vision of this library is to implement deep learning solutions like image classification, style transfer, and text generation with high-level methods React Native to make it possible for anyone to create fully functional deep learning apps.

Click here to know more about this library:

The famous HBO show Silicon Valley actually released an app that identifies whether an image is a hotdog or not!

This was done by creating an artificial neural network that runs directly on your phone. The neural network was then trained using TensorFlow, Keras and Nvidia GPUs.

While this may be a superficial app with no real use-cases, it is a great example of Deep Learning React Native app. The AI is 100% powered by the user’s device, and images are processed without every leaving the phone. This way, the app manages to provide the users with fast performance, offline availability, and better privacy.

Check out this codelab to learn how to train your own classifier using TensorFlow

And thank you for reading! Please do 👏 if you liked it.

Add a comment

Related posts:

Create Android apps using MVVM with Clean Architecture

The crux of the story is to undertand the benefits of maintaining Clean Architecture with respect to the growth of application codebase i.e., features and expansion of the team for that matter. It’s…

Tacuma Ogunseye as a Scapegoat

Tacuma Ogunseye recently surrendered to the police in Guyana. He is being accused of violating section 2 (3) of the Racial Hostility Act. I have expressed in prior articles that I did not agree with…

Redesign Site de Ofertas

Comecei a estudar UX há pouco tempo, entrei em grupos de Facebook de profissionais da área e as dicas para os recém-chegados eram: Estude, faça cursos e mão na massa para construir um portfólio. Com…