Machine learning, Raspberry Pi, Robotics

Machine Learning with Raspberry Pi

Although Machine learning appears as a high-tech term, we come across it every day without knowing it. For example tasks such as filtering of spam mails, automatic tagging of facebook photos are accomplished by Machine learning algorithms.   In recent years a new area of Machine learning, known as deep learning is getting lot of  attention, as a promising route for achieving artificial intelligence.

Until recently this knowledge of deep learning is confined to only big data centers. This is because,  the deep learning technology requires large amount of data sets, which only big data mining firms such as Google, Facebook, Microsoft have access to. To keep this technology in every one’s hand, a new startup  Jetpac  has given the access to their deep learning technology to everyone with a computing device (check their app). This is exciting because, many people have  mobile phones, which have so much of computing power. Just see what can be done with such kind of democratization of technology in the above video.

Now coming to the Raspberry Pi, it has roughly 20 GFLOPS (almost same as the Parallela board offers) of computing power, thanks to its GPU. After Broadcam has released the documentation for the GPU specs, Pete Warden has done a great job by porting his Deep Belief Image recognition SDK to the Raspberry Pi. Today after seeing about this post in the Raspberry Pi Blog, I have tried to follow his instructions and successfully run the first example on my Pi.

Instructions to install Deep Belief on Raspberry Pi

This algorithm requires at least 128 MB of RAM dedicated to GPU. To allocate that, we need to edit /boot/config.txt. We do it by using the following command

sudo nano /boot/config.txt

Then add the following line at the end of  /boot/config.txt


save and exit the editor. Now we have to reboot the Raspberry Pi to get a ‘clean’ area of memory.

sudo reboot

Install git by using the following command

sudo apt-get install git

We are now ready to install the Deep belief. Just follow the below instructions

git clone
cd DeepBeliefSDK/RaspberryPiLibrary
sudo ./

That’s it. You have installed one of the best Machine learning algorithm on Pi. Now to test whether everything is working or not, hit the following commands.

cd ../examples/SimpleLinux/
sudo ./deepbelief 

If everything goes well, you should see the following output

0.016994    wool
0.016418    cardigan
0.010924    kimono
0.010713    miniskirt
0.014307    crayfish
0.015663    brassiere
0.014216    harp
0.017052    sandal
0.024082    holster
0.013580    velvet
0.057286    bonnet
0.018848    stole
0.028298    maillot
0.010915    gown
0.073035    wig
0.012413    hand blower
0.031052    stage
0.027875    umbrella
0.012592    sarong

Pete Warden has explained how to implement this algorithm for various applications on Gitgub. I would like to use this for my Robotic project, so that my robot can recognize the objects around it, just like the Romo in the above video. I am planning to do this with Open CV.


If you don’t allocate sufficient RAM for GPU, you may get the following error.

Unable to allocate 7778899 bytes of GPU memory
mmap error -1


Raspberry Pi, Robotics

Raspberry Pi Notes


Today, I am going to share some of my frequently used things with Raspberry pi.

Change password:


For safety purposes , it is important to change the default password.

Just type the following command, it will bring the change password option.

sudo raspi-config

You are asked to type the new password twice.


Update and upgrade Raspberry pi:

sudo apt-get update

sudo apt-get upgrade

sudo apt-get update && sudo apt-get install rpi-update

The first two commands will update the  software packages.

The  last command will update the firmware.

Look into the below link for more details.


Save some disk space:

To see the disk space hit the command

df -h

Now to clean some archived files use the following command, that will free up some space

sudo apt-get autoclean


Safely shutdown Raspberry pi:

The following command will safely shutdown your pi

sudo shutdown -h now


Clone your sdcard:


Once downloading and upgrading your preferred settings, it is best to save these settings permanently. For this purpose, we use Win32DiskImager.

Start Win32DiskImager, and in the image file option, give the folder path  in your computer where you want to save settings as .img file. insert the sd card and select the win32diskimager.

Now  just press “read” tab. That’s it, you cloned your sdcard.

Next time, if your sd-card get corrupted, or you wanna restore your previous settings, just insert your sd-card, and chose this cloned .img file in win32diskimager.

setup VNC player:

I run my Raspberry pi headless, so it is very handy for me to see the desktop of pi with vnc player. The following command will install tightvnc server on pi.

sudo apt-get install tightvncserver

First time you require to set-up the password. So hit the following command


On windows computer, I install tightvnc viewer and xming to see the Pi’s desktop.

For more detailed steps, see the excellent tutorial in the following guide