Published on

10 Minute Introduction to Deep Neural Networks with Python (Part 1)

In this blog post series, we will be learning about deep learning with Python (very very briefly). We begin with the introduction to Machine Learning.


Introduction to Machine Learning

We start with a basic question. What is a machine?

What is a Machine?
def machine():
  for i in range(1):
    print("Am I a machine ?")

machine()

And, the next question will be What is learning?

What is learning?
def learning():
  experience = 3
  while experience > 2:
    print("Is this learning?")
    experience -=1

learning()

So what exactly is Machine Learning?

ML

We have a famous definition of machine learning by Tom Mitchell here:

A computer program is said to learn from experience E with respect to some task T and some performance measure P, if its performance on T, as measured by P, improves with experience E.

Do you think of any examples here? 🤔

If you answered that question to yourself, well, congratulations! But, there is a much more important question here.

Why do we want to teach something to a machine?

Why not simply define its task and let it perform. For years, machines could do this, and they helped us a lot. Tricky problems.

Imagine we want a tool to recognize the digits in a handwritten document. Sounds, well, not so hard, right? There are 9 digits in total, and if we can define the characteristic of each digit, then the machine should be able to recognize all the texts. Well, technically correct, but we forget about something. EVERYBODY WRITES DIFFERENTLY. Seriously, remember all those handwritten digits you have seen in your life. Weren't you surprised to find out how many different ways to draw a digit "7" ?? How can we explain to the machine all those different "7" digits it's going to see ??

Machine learning to the rescue

So we need a program that will recognize the handwritten digits for us.

Digits

Wait, we can hire a guy to do that for us, right? His duty will be reading all those handwritten digits and typing them into a text document for us. PROBLEM SOLVED.

Oooorr, we can teach the computer to recognize the digits, and we won't need to waste somebody's life for this simple task. But how do we teach the machine? That will be the topic of another blog post, but basically, we will show as many handwritten digit images to the computer as we can, and we will say "Hey machine, you see this image? This is digit 7". We will do this many, many, many, many times, and eventually, the machine will learn each digit.

In fact this handwritten digit problem caused the birth of convolutional neural networks in 1989. Just search for MNIST recogniton by Yann LeCUN and you can read about it.

MNIST digits

Okay we saw that computers can recognize digits, congratulations, well done, how about more advanced tasks ?

How abouut, playing Chess? It has been used to match wits with someone by humans for centuries in the end. So, how do machines perform in this game? They cannot beat humans with all those centuries' worth of experience, right?

Well, sadly (or excitedly), they can do much more than that.

There is the famous AlphaZero developed by Google Deepmind which destroys all opponents. The funny part is AlphaZero itself is 9 hours old, just 9 hours. During the learning phase, it was just given the rules of Chess, and then it played against itself, many times, many many times, around 44 million games.

AlphaZero

If you want to read more about the AI in Chess, go here: AI in Chess

This Machine Learning sounds interesting; tell me more about HOW we can do this?

Okay, so we all agree ML is nice and cool. If we don't just go to this website to change your mind about ML and come back here as an impressed reader. COOL AI EXAMPLES

For applying machine learning with Python, there are just some nice libraries we use a lot. Let's mention them.

ML Libraries

Numpy

You will always see NumPy if you have anything to do with data in Python. It provides valuable tools for mathematical operations, high dimensional matrices, etc.

It's gentlemen's agreement to import numpy as np 😎

import numpy as np

Pandas

Pandas provides useful functions to work with data. If you are working with tables, trying to read data from external files, etc. Pandas is your best friend.

Another gentlemen's agreement applies here; you must import pandas as pd 😎

import pandas as pd

Scikit-Learn

Scikit-learn (sklearn) provides numerous valuable functions if you are diving into non-deep learning machine learning (confusing sentence, I know 🥸). It also provides useful functions for measuring performance metrics (PSNR, SSIM, F1-Score, etc.)

import sklearn

TensorFlow and PyTorch 🔥

These are the big guys and are supported by them (TF = Google, Pytorch = Facebook). Two main deep learning frameworks, basically. You can't go wrong with any of them, but PyTorch is preferred for research, and TensorFlow is preferred for production/real-world implementation.

We also have another gentlemen's agreement for TensorFlow: import as tf 😎

import tensorflow as tf
import torch

This is the end of this introduction. If you liked what you read, you could continue with the following post to learn about the famous Deep Learning. See you there!