Monday, December 26, 2016

CPU v GPU (Deep learning \ AI)

Why bother about CPU v GPU? Because this will let you know how parallel processors making revolution in the Deep Learning \ AI world.

CPU or Central Processing Unit: is electronic microprocessor which is designed to do sequential processing of tasks/programs as described by von Neumann Architecture (1945). Neumann was working on Manhattan project at Los Alamos National Laboratory, he wanted to device a machine to do lot of calculations. So Neumann designed CPU architecture, obviously he was influenced by the great Alan Turing, British mathematician. 

The reason I am trying to give background of CPU is to understand the time its architecture was designed.

GPU or Graphics Processing Unit: many of us don’t know that GPU exist in almost all modern computer, mobile phones or any display units. It’s the work horse, does all the graphics related activities like calculating vectors\polygons or all activities involved in the graphics pipeline. In short to do math required to displaying video games\movies, images is responsibilities of GPU. 

Initially CPU is to do all graphics processing related activities, but the raise of the sizes of movies, video games, images let to the raise of GPU’s. Actually still CPU is central of a computer, but it just outsource the graphics processing work to GPU. GPU is capable of doing many times billions of calculations per second then CPU because of its enormous number of its cores. 

CPU v GPU 

“A CPU consists of a few cores optimized for sequential serial processing while a GPU has a massively parallel architecture consisting of thousands of smaller, more efficient cores designed for handling multiple tasks simultaneously” NVidia


CPUs & GPUs both have fundamentally different design philosophies. We cannot compare apple to orange. Each excel at their own respective domain. Here is the few basic difference between them:

CPU
GPU
Multiple cores
Hundreds or thousands of Cores
general purpose processors to handle all kind of activities
special purpose processors to handle polygon based 3d graphics
serial portions of the code run
parallel portions of the code run
have higher operating frequency, higher of number of registers
- lower operating frequency, lower number of registers
file handling, branching, serial tasks
better in math computer like polygons, vector math’s, transformation

GPUs are in general targeted for gaming.
Sequential
Parallel

Deep learning:

With rapid advancement of GPU’s processing power researchers and business started to use it in Deep learning \ AI   

Deep learning is the fastest-growing field in artificial intelligence, helping computers make sense of infinite amounts of data in the form of images, sound, and text” - nvidia

Deep learning is nothing but trying to solve complex problems by creating neural networks which works like human brain. It learns from the process it does and try’s evolve or get better as it does more and more operations. Basically try’s to become like one human brain.  

Today’s advanced deep neural networks use algorithms, big data, and the computational power of the GPU to change this dynamic. Machines are now able to learn at a speed, accuracy, and scale that are driving true artificial intelligence.

Deep learning is used in the research community and in industry to help solve many complex problems like genetic simulation, molecular biology simulation etc.

Parallel Processors Framework

Following API’s helps programmers to manage parallelism and data delivery in massively parallel processors (GPU’s): 

OpenCL by Apple
DirectCompute by Microsoft
CUDA by NVidia

By using any above frameworks you can write programs to analyze or solve problems like complex math calculation, molecular simulation, genetics or even atom level simulations.


Sunday, December 4, 2016

What is IoT?



What is IoT. Internet of things or devices connected to internet.

In simple words the devices which are connected to internet, interact with each other, collect and exchange data. A device is connected to internet can be controlled or operated by remote control room.

History:

Necessity is the mother of invention, Retail industry were struggling to track the items, inventory, to meet demand and supply. Researchers at MIT found a way to improve Procter and Gamble business by linking RFID info to the internet, and also with the invention of RFID, internet led to the era of IoT.

Term IoT was first coined by Peter T Lewis in 1985 speech to FCC, he said “IoT is the integration of people, processes and technology with connectable devices”.
Kevin Ashton is one of key member in development of IoT, while working at MITs autoID lab developed technique to linking RFID information to the internet.  Ashton wrote:
“RFID and sensor technology enable computers to observe, identify and understand the world—without the limitations of human-entered data”

Though its simple automation solution at that time but not simple anymore now.


Bottom line of IoT are automation, no human intervention, less errors, improve productivity, machine to machine communications, cost savings.

Things which make IoT to work: (Sensor | IP number | Internet | Cloud | You)


Actually its convergence of multiple technologies makes IoT to work. But here are the main components of IoT:
Sensor:a device that detects or measures a physical property and records, indicates, or otherwise responds to it” – wiki. It can any sensor heat, pressure, bio, touch, … if you don’t know, your (human) body is full of sensors!!
IP number: thanks to IPv6, without this it’s tough to implement IoT. IPv6 is based on 128 bit address so theoretically 2 ^ 128 addresses. Based on ipv6 we can assign a unique number to each device.
Internet:  another major component through this we transfer data or communicate.
Cloud: via internet we store the sensor data, process and analyze it
You: you or smart phone or machine will have the information about a device. You will decide what to do with that data.

Here is a hypothetical scenario of how above components work together:
You have installed a temp monitor Sensor at your home. Sensor detects that air temperature inside your home is above 85 deg F. Sensor has connected to internet, so it will send data to cloud. Your smartphone is hooked up to cloud data or registered to receive alert from cloud. So on cloud you have logic if data of air temperature rise above certain level you inform registered devices. So you get an alert notification. You can respond to that alert by saying to reduce the temperature.  In reverse order signal goes to cloud, cloud to sensor via internet and sensor reduces the temperature.

IoT is heavily used in Industrial automation, Health care, Power & Utilities and many other. You can even monitor your refrigerator too.

Create your own IoT device:


With little effort you can create your own IoT device. I have listed things you need to create a device.

Scripting/Programming language. (ex: Python, C)
You need to know a scripting\programming language. With very basics if else conditions you can create script to-do on and off functionality.  If you need here is the link to learn python.
https://wiki.python.org/moin/BeginnersGuide/Programmers

Basics of Electronics
You should know basics of electronics like voltage, current, resistors, capacitors and couple others. Here is the link if you need to learn or brush up.
https://www.clear.rice.edu/elec201/Book/basic_elec.html

Arduino or Raspberry pi
Both are often misunderstood about the usage. Here is basic difference of them:
Arduino is a microcontroller / basic computer, you can run just one program at a time. (Costs around 20$)
Raspberry pi is full-fledged computer with Linux OS. You can run multiple programs at a time. (Costs around 35$)

I suggest you start with Arduino, because it’s simple and easy to learn.

Download Arduino IDE: https://www.arduino.cc/en/Guide/HomePage
Buy Arduino basic controller
Follow: https://www.arduino.cc/en/Tutorial/HomePage