Showing posts with label Deep Learning. Show all posts
Showing posts with label Deep Learning. Show all posts

Tuesday, April 18, 2023

Installing TensorFlow on Pop!_OS using Tensorman

Pop!_OS allows easy installation and management of Tensorflow using 'tensorman'.

Installing TensorFlow on Pop!_OS using Tensorman
Installing TensorFlow on Pop!_OS using Tensorman

First, make sure you have all the updates installed:

sudo apt update
sudo apt full-upgrade

Then, install the tensorman package:

sudo apt install tensorman

 In order to get Nvidia CUDA support, install the nvidia docker package:

sudo apt install nvidia-docker2

Thursday, October 8, 2020

Accuracy of Deep Learning Models Over the Years

Over the years, there were many achievements in deep learning, many of which were directly related to the ImageNet Large Scale Visual Recognition Challenge (ILSVRC, or ImageNet challenge for short). We talked about some of those milestones in deep learning in the past and how their unique innovations have helped shape the deep learning landscape today.

Today let us look at how the accuracy of these significant models has increased over the years.

Deep Learning Models Over the Years
Deep Learning Models Over the Years


When reporting the accuracy of classification models two accuracy measures are typically used: Top-1 Accuracy, and Top-5 Accuracy.
  • Top-1 Accuracy - Where the highest probability/confidence prediction from the model matches the expected class
  • Top-5 Accuracy - Where the expected class is within the top 5 predictions of the model

Thursday, October 1, 2020

Pre-orders are Now Open for Deep Learning on Windows

Pre-orders for my new book, Deep Learning on Windows, are Now Open at Amazon.com!

Deep Learning on Windows is my latest book, and it is the longest and the most comprehensive book I have written to date. The book is meant for both beginners and intermediates to deep learning. It covers topics from setting up your tools on Windows and getting started, to complex but fun topics in deep learning and computer vision.

The Cover of 'Deep Learning on Windows'
The Cover of 'Deep Learning on Windows'



The Windows OS accounts for over 70% of the desktop PC usage. Windows provides many conveniences, with a wide variety of available productivity tools, causing it to gather a large userbase. This means that there is a large percentage of you - AI enthusiasts and developers - out there that primarily work on the Windows OS, and would prefer to develop deep learning models on Windows itself.

Wednesday, September 16, 2020

Major Update on My New Book: Deep Learning on Windows

If you recall, I originally intended to incrementally release my new book - Deep Learning on Windows – and have it completed around the June/July timeframe. Well, the month of July came and went, but no book got released. I also was not posting articles in the blog frequently for the past couple of months.

This was due to a major change in the plan for the book.

Deep Learning on Windows was picked up by a publisher!

The book will now be published under Apress, and it became a much larger offering than what I initially envisioned.

The new cover for the book is shown below:

New Cover for Deep Learning on Windows
New Cover for Deep Learning on Windows


On late-May, while I was working on the first drafts of the book on LeanPub, I was contacted by Apress on whether I would be interested in publishing the book under Apress banner. 

Tuesday, April 21, 2020

Book Update: First 3 Chapters are Now Released!

I'm excited to let you know that the first 3 Chapters of my new book - Deep Learning on Windows - is now released at LeanPub!

Deep Learning on Windows - Cover
Deep Learning on Windows

This is currently the only book focusing specifically on setting up and developing Deep Learning models on Microsoft Windows. As I mentioned in my earlier post, most of the queries and questions I have received over the past year or so were related to building deep learning models on the Windows OS, and how-to setup and troubleshoot the tools on it. There were very little material out there addressing Windows specifically.

So, this book is my answer to that.

A total of 12 chapters are planned for the book, covering topics from setting up your tools on Windows, building your first models, to some advanced topics like transfer learning, deploying your models, computer vision, generative adversarial networks, and reinforcement learning.

The book will be released in an incremental manner. The first 3 chapters are now released.
Buying the book now guarantees that you will get all the remaining content, and all future updates and revisions for free as they get released.

The price of the book will increase over time as new chapters gets added, so purchasing early gives you the best value.

Tuesday, April 7, 2020

My New Book is in the works: Deep Learning on Windows

Hope you all are staying safe!

With the lockdown and working from home from my job I've had a bit of free time these past few days. I've spent some of that time on going through the comments of the blog, and the questions and queries I have received from you readers through email and social media channels.

What I was trying to do was to identify any major areas you are struggling in, and try to come up with solutions to address those areas.

What I found was that, most of the queries were related to building deep learning models on the Windows OS, and how-to setup and troubleshoot the tools on it.

So, as a means of addressing this area, I've decided to start writing a new book, which will be named "Deep Learning on Windows".

"Working" Cover Page of the New Book
"Working" Cover Page of the New Book (cover would change in the final version)

Materials and support for setting up deep learning frameworks and building models on Windows is a little bit scarce out there. This is mainly because native support for Windows in many of the popular tools were not there until recently.

This is why I decided to write a book specifically on getting deep learning development started on Windows.

Monday, December 9, 2019

Deep Learning, AI/ML, Computer Vision, and Data Science Gift Buying Guide - 2019

It’s the holiday season! This is the season of the year we like to celebrate the most. And it is the part of the year that we'd like to give, and receive, gifts.

While it's easy to pick a gift (relatively speaking) for some people, the interests of some others might make it hard nail down a gift for. (Take an AI, ML, Data Science and programming enthusiast like me for an example)

Now, you might have a family member, colleague, or a friend that is into AI, Deep Learning, and Machine Learning. Or, they might be working on or interested in Data Science or Computer Vision. You might be wondering what sort of gifts to get them.

Or simply as an enthusiast in those areas yourself, you're thinking of buying a gift for yourself this season. (I know that I’m thinking the same)

So, how do you select a gift for someone with interest in such vast and technical fields?

Well today I’m going to give you some gift ideas that just might work.

AI, ML, Deep Learning, Computer Vision, and Data Science Gift Guide 2019


When thinking of gifts relating to the AI/ML, CV, Data Science fields, we can consider three categories of gifts,

  1. Items to Improve their ability to perform tasks in those areas
  2. Give them new tech toys to play around in those areas
  3. Help them improve their knowledge in those areas

Let’s see what items we can select for each of those categories.


Monday, January 15, 2018

OpenAI and the Dota 2 Bot

OpenAI – a non-profit AI research company, founded by Elon Musk and Sam Altman, which focuses on developing friendly AI – unveiled their Dota 2 AI Bot in August 2017, which is capable of defeating top Dota professional players in 1v1 matches.

OpenAI Logo
OpenAI Logo

Dota 2 is a multiplayer online battle arena (MOBA) game developed by the Valve Corporation. First released on July 2013, the game is a sequel to the community game Defence of the Ancients (DotA) which was released back in 2003 as a mod for the game Warcraft III.

The Dota 2 Game Logo
The Dota 2 Game Logo

A typical match of Dota 2 is played by five-verses-five (5v5), although other variations of the game exists, such as 1v1. The players each choose a ‘hero’ from 115 playable characters, each with its strengths and weaknesses, and various abilities and powers. The game is played in a real-time strategy manner, where each ream battles the other and attempts to destroy the ‘Ancient’ (the large structure on their base) of the opposing team while defending their own.

Friday, December 8, 2017

What is AlphaGo, AlphaGo Zero, and AlphaZero

AlphaGo – developed by the DeepMind team of Google – is an AI program which plays the board game Go.

A Go board (By Donarreiskoffer - Self-photographed, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=43383)
A Go board (By Donarreiskoffer - Self-photographed, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=43383)


The Go board game is an abstract strategy game, which has been invented in China over 2500 years ago. Despite its simple set of rules, Go is considered to be much more complex than Chess, and is one of the most studied strategy game of all time.

The AlphaGo Logo
The AlphaGo Logo

The AlphaGo uses a Monte Carlo tree search algorithm to find moves using the trained deep neural network which works as its knowledge core. AlphaGo was initially trained on a training set of over 30 million moves data from human Go matches. It was then further trained by letting it compete against copies of itself using reinforcement learning.

Wednesday, August 30, 2017

Build Deeper: Deep Learning Beginners' Guide

I've been away from writing a post for about three weeks. That's because I've been preparing something exciting.

Today, I'm happy to announce the first book release from Codes of Interest - Build Deeper: Deep Learning Beginners' Guide.

Build Deeper: Deep Learning Beginners' Guide
Build Deeper: Deep Learning Beginners' Guide

Deep Learning has become a household name. It’s the bleeding edge in AI, and already achieving some phenomenal feats. Breakthroughs are happening daily, and the tech giants are not only pursuing it, they’re leading it.

Build Deeper: Deep Learning Beginners' Guide is the ultimate guide for anyone taking their first step into Deep Learning. Learn what Deep Learning is, and how it came to be. See what it's capable of, and its milestones. And get hands-on with building your first Deep Learning model.

All you need to get started is a bit of enthusiasm, and some basic programming skills.

Build Deeper: Deep Learning Beginners' Guide is now available from Amazon.



Tuesday, August 8, 2017

Using Bottleneck Features for Multi-Class Classification in Keras and TensorFlow

Training an Image Classification model - even with Deep Learning - is not an easy task. In order to get sufficient accuracy, without overfitting requires a lot of training data. If you try to train a deep learning model from scratch, and hope build a classification system with similar level of capability of an ImageNet-level model, then you'll need a dataset of about a million training examples (plus, validation examples also). Needless to say, it's not easy to acquire, or build such a dataset practically.

So, is there any hope for us to build a good image classification system ourselves?

Yes, there is!

Luckily, Deep Learning supports an immensely useful feature called 'Transfer Learning'. Basically, you are able to take a pre-trained deep learning model - which is trained on a large-scale dataset such as ImageNet - and re-purpose it to handle an entirely different problem. The idea is that since the model has already learned certain features from a large dataset, it may be able to use those features as a base to learn the particular classification problem we present it with.

This task is further simplified since popular deep learning models such as VGG16 and their pre-trained ImageNet weights are readily available. The Keras framework even has them built-in in the keras.applications package.

An image classification system built with transfer learning
An image classification system built with transfer learning


The basic technique to get transfer learning working is to get a pre-trained model (with the weights loaded) and remove final fully-connected layers from that model. We then use the remaining portion of the model as a feature extractor for our smaller dataset. These extracted features are called "Bottleneck Features" (i.e. the last activation maps before the fully-connected layers in the original model). We then train a small fully-connected network on those extracted bottleneck features in order to get the classes we need as outputs for our problem.

Friday, July 7, 2017

Milestones of Deep Learning

Deep Learning has been around for about a decade now. We talked about how Deep Learning evolved through Artificial Intelligence, and Machine Learning (See "What is Deep Learning?"). Since its inception, Deep Learning has taken the world by storm due to its success. Here are some of the more significant achievements of Deep Learning throughout the years,

AlexNet - 2012


The AlexNet Architecture
The AlexNet Architecture (Image from the research paper)

  • Proved that Convolutional Neural Networks actually works. AlexNet - and its research paper "ImageNet Classification with Deep Convolutional Neural Networks" by Alex Krizhevsky, Ilya Sutskever, and Geoffrey E. Hinton - is commonly considered as what brought Deep Learning in to the mainstream.
  • Won 2012 ILSVRC (ImageNet Large-Scale Visual Recognition Challenge) with 15.4% error rate. (For reference, the 2nd best entry at ILSVRC had 26.2% error rate).
  • 8 layers: 5 convolutional, 3 fully connected.
  • Used ReLU for the non-linearity function rather than the conventional tanh function used until then.
  • Introduced the use of Dropout Layers, and Data Augmentation to overcome overfitting.
Research Paper: ImageNet Classification with Deep Convolutional Neural Networks - Alex Krizhevsky, Ilya Sutskever, Geoffrey E. Hinton

Wednesday, June 28, 2017

Machine UI : An IDE for Machine Learning, currently in Alpha

Machine UI, or just "Machine" as it's commonly referred, is an IDE for Machine Learning, which is currently in its Alpha stage. It has been designed to work with TensorFlow, and aims at simplifying setting up machine Learning experiments so that you spend more time experimenting, and less time configuring.


The interface of Machine UI
The interface of Machine UI (Note: This is a screenshot from their announcement video)

As per their announcement video, the machine learning experiments are set up visually. The input data, convolutions, and the outputs are placed as nodes on a graph. You can think of it as a more interactive version of the Tensor Board which comes with TensorFlow.

Friday, June 9, 2017

Wink Detection using Dlib and OpenCV

A couple of weeks ago, I was going through a tutorial for eye blink detection by Adrian at PyImageSearch. It was an excellent tutorial, which explained the use of Eye Aspect Ratio (EAR) in order to detect when an eye gets closed. Then, few weeks back, I was having a chat with Shirish Ranade, a reader of this blog and a fellow computer vision and machine learning enthusiast, on whether we can perform an action by winking at the computer. So, I decided to try out a code to detect winking.

Wink Detection Running with Dlib and OpenCV
Wink Detection Running with Dlib and OpenCV
It's an interesting idea to perform an action or a task just by winking at your computer. It can be thought as a form of gesture detection or facial expression detection as well. So, here's how you can build your own 'wink' detector for it.

We start by importing all the necessary packages,
 import numpy as np  
 import cv2  
 import dlib  
 from scipy.spatial import distance as dist  

Thursday, May 18, 2017

What is Deep Learning? - Updated

What is Deep Learning? And, how does it relates to Machine Learning, and Artificial Intelligence?

I did an article to answer these questions some time back.

Now, thanks to the feedback I got from you all, I was able to updated it, with more clarifications, improved examples, and answers to more questions in Deep Learning.


Check out the updated article here,


Your feedback are always welcome.

Build Deeper: Deep Learning Beginners' Guide is the ultimate guide for anyone taking their first step into Deep Learning.

Get your copy now!

Thursday, April 13, 2017

How deep should it be to be called Deep Learning?

If you remember, some time back, I made an article on What is Deep Learning?, in which I explored the confusion that many have on terms Artificial Intelligence, Machine Learning, and Deep Learning. We talked about how those terms relate to each other: how the drive to build an intelligent machine started the field of Artificial Intelligence, when building an intelligence from scratch proved too ambitious, how the field evolved into Machine Learning, and with the expansion of both the capabilities of computer hardware and our understanding of the natural brain, dawned the field of Deep Learning

We learned that the deeper and more complex models (compared to traditional models) of Deep Learning are able to consume massive amounts of data, and able to learn complex features by Hierarchical Feature Learning through multiple layers of abstraction. We saw that Deep Learning algorithms don’t have a "plateau in performance" compared to traditional machine learning algorithms: that they don’t have a limit on the amount of data they can ingest. Simply, the more data they are given, the better they would perform.

The Plateau in Performance in Traditional vs. Deep Learning
The Plateau in Performance in Traditional vs. Deep Learning


With the capabilities of Deep Learning grasped, there’s one question that usually comes up when one first learns about Deep Learning:

If we say that deeper and more complex models gives Deep Learning models the capabilities to surpass even human capabilities, then how deep a machine learning model should be to be considered a Deep Learning model?

I’ve had the same question when I was first getting started with Deep Learning, and I had few other Deep Learning enthusiasts asking me the same question.

It turns out, we were asking the wrong question. We need to look at Deep Learning from a different angle to understand it.

Let’s take a step back and see how a Deep Learning model works.

Thursday, January 19, 2017

New Page - What is Deep Learning?

Deep Learning is the latest trend in Machine Learning. We hear about new innovations in Deep Learning every day, to a point that it has started to become a household name. Big companies such as Google, Apple, Amazon, Microsoft, IBM, and many others seems to be pushing for Deep Learning.

But, do you know what Deep Learning really is?

http://www.codesofinterest.com/p/what-is-deep-learning.html

Since it's one of the most frequent questions that comes up, I created a new page "What is Deep Learning?" which talks about what Deep Learning is, how it relates to Machine Learning and Artificial Intelligence, and their history. Have a look at it from the below link,


Let me know what you think of Deep Learning.

Build Deeper: Deep Learning Beginners' Guide is the ultimate guide for anyone taking their first step into Deep Learning.

Get your copy now!

Friday, December 9, 2016

What is a Tensor?

Whether you are new to the field of Deep Learning, or might be coming from bit of a Machine Learning background and just dipping your toes into Deep Learning frameworks, you might be coming across the word "Tensor". Specially, with the increasing popularity of TensorFlow - the 2nd generation Machine Learning library by the Google Brain Team - the concept of the "Tensor" has also gained popularity.

You may be thinking that a Tensor is probably a mysterious and complicated thing, used exclusively in Machine Learning algorithms. But in reality, a Tensor is something quite simple and common.

So, what is a Tensor?

A representation of a Tensor
Image courtesy: Wikipedia - https://commons.wikimedia.org/wiki/File:Components_stress_tensor.svg

A Tensor is simply a data structure. A much more generic representation of any of the data collections we see in programming languages. However, unlike any other data structures, typically the position of a value in a Tensor has a meaning (we'll get to that in a bit).

A Tensor may have zero or more dimensions, which is given as the 'Order' of a Tensor.

A scalar, or a single number is a Tensor of order zero, which can also be thought as an array of dimension zero.

A Tensor of order one would be a Vector, or a one-dimensional array.

A Tensor of order two would be a matrix, or a two-dimensional array.

And so on... Tensors of any order can be made.

As I mentioned above, in typical use cases, the position of a value in a tensor - commonly referred to as the coordinates - has a meaning, and the value would transform according to the rules we define when the coordinates are changed.

For an example, we can define a tensor of order two which contains the pixel values of a grayscale image. In this case, the coordinates of the values of the tensor would represent the X and Y coordinates of the pixels of the image, and the values themselves would be the grayscale values at those coordinates. And, as you expect, if you transform the coordinates, the values would also change.


Related links:
http://www.physlink.com/education/askexperts/ae168.cfm
https://en.wikipedia.org/wiki/Tensor
http://mathworld.wolfram.com/Tensor.html

Build Deeper: Deep Learning Beginners' Guide is the ultimate guide for anyone taking their first step into Deep Learning.

Get your copy now!

Saturday, November 12, 2016

Getting the LeNet model working with Face Recognition

In my last post, I talked about how the LeNet Convolutional Neural Network model is capable of handling much more complex data than the intended MNIST dataset. We saw how it got ~99% accuracy when it learned to identify 10 faces from the raw pixel intensities.

So, let’s see the code I used to get it working.

First of all, I needed a training dataset. For that, I created a set of face images of 10 subjects with around 500 images each.

Few of the images from the training dataset
The training dataset (yep, that's my face)

I use a file naming convention as <subject_label>-<subject_name>-<unique_number>.jpg (e.g. 0-Thimira-1475137898.65.jpg) for the training images to make it easier to read in and get the metadata of the images in one go. (I will do a separate post on how to easily create training datasets of face images like this).

We'll mainly be using Keras to build the model, and scikit-learn for some utility functions. We’ll need to import the following packages,
 from sklearn.cross_validation import train_test_split  
 from keras.optimizers import SGD  
 from keras.utils import np_utils  
 import numpy as np  
 import argparse  
 import cv2  
 import os  
 import sys  
 from PIL import Image  

Monday, November 7, 2016

Can the LeNet model handle Face Recognition?

I recently followed a blog post - at PyImageSearch by Adrian Rosebrock - on using the LeNet Convolutional Neural Network model on the MNIST dataset - i.e. use for handwritten digit recognition - using Keras with Theano backend. I was able to easily try it out thanks to the very detailed and well thought out guide.

The LeNet model itself is quite simple, just 5 layers. Yet it performs impressively well on the MNIST dataset. We can get around 98% accuracy with just 20 iterations of training with ease.

The training time for the model is also quite low. I tested on my MSI GE60 2PF Apache Pro laptop with CUDA enabled, and the training time was just 2 minutes 20 seconds on average. On CPU only (with CUDA disabled) it took around 30 minutes.

LeNet giving 98% accuracy on MNIST data
LeNet giving 98% accuracy on MNIST data
As you can see, we got 98.11% accuracy, and it has correctly classified a digit that has been cut-off.

It even classifies a quite deformed '2' correctly.
LeNet correctly classifying a deformed digit
LeNet correctly classifying a deformed digit