One-Shot Learning - Fresh Machine Learning #1

Siraj Raval · Beginner ·📐 ML Fundamentals ·10y ago

Key Takeaways

The video demonstrates One-Shot Learning using a handwritten character classifier in Python with SciPy, exploring the concept of learning with few examples and its potential to democratize machine learning.

Full Transcript

you only get one shot do not miss your chance to blow opportunity it actually takes more than one shot to train a [Music] model hello world it's SJ and welcome to fresh machine learning this course is all about making bleeding edge machine learning accessible to developers the field is moving faster than Steve Balmer at a developer conference developers developers developers we're going to learn to apply some of the latest machine learning techniques to practical examples that you can integrate into your own apps neural networks have been around since the ' 50s but we've just never had as much data and computing power as we do now we call it deep learning these days and it deserves the Press it's gotten but so many articles claim it replicates the human brain some even make it sound like if we give a deep neural net enough data and compute it'll suddenly become self-aware M the brain is indeed a neural network but do we really learn the way a deep neural net does well let's think about it in order for a deep neural net to learn to say recognize an image of a banana you first have to feed it hundreds of thousands of banana images but think about the way you and I learn if I were to show you an image of a banana for the first time you'd probably be able to recognize a novel banana instantly even if it was a different shape or color we humans don't seem to need thousands of examples just to generalize just a few and we learn richer representations than machines do as well we can use the concepts we learn in other ways like creating new examples if we could create an algorithm to do this to learn concepts with few examples wouldn't that be incredible it would further democratize the field so that not just the big companies like Google and Amazon with huge private internal data sets are able to train their models but anyone can so is there an algorithm that does this well there was a recent paper that came out called human level concept learning through probabilistic program induction the author said let's build a model capable of what's called oneshot learning onshot learning is a type of ml that learns an object category after just one or a few examples oh they use something called basian program learning or BPL to do this basian refers to B theorem which attempts to use Simple stochastic programs to represent Concepts the word stochastic referring to the theory of probability is what base theorem Loosely revolves around so by using simple stochastic programs or probability algorithms BPL can represent Concepts BPL builds these simple stochastic programs compositionally from parts subp parts and spatial relations all these things exist in a hierarchy of knowledge which the machine has gained through little experience so they trained it on a data set of handwriting characters and it was able to recognize characters with the better error rate than deep learning or even humans so does that mean that BPL is a way to go well it does have its flaws it lacks explicit knowledge of certain things like parallel lines Symmetry and connections between ends of strokes and other strokes and the learning isn't really transferable to other things so it's not better than deep learning in every way a few months later though Deep Mind challenged the paper by releasing their own called oneshot learning with memory augmented neural networks the basic idea they had was that deep learning is very data intensive but perhaps there's a way to build a deep neural net that only needs a few examples to learn deep learning without the huge data sets so they built what's called a memory augmented neural network a man has two parts a controller which is either a feed forward neural net or lstm neural net and an external memory module the controller interacts with the external memory module with a number of read write heads it's capable of long-term storage via slow updates of the weights and short-term storage via the external memory module they FedEd a few examples of handwritten characters and continuously trained it thousands of times on just those examples and guess what it outperforms humans as well so they prove that one shot learning can be accomplished by using a neural network architecture which is pretty dope so there are lots of methodologies to implement oneshot learning and in this episode we're going to implement our own we're going to build a onot handwritten character classifier in Python using the scipi library so hold on to your butt we got to import our dependencies first we're going to want three libraries numpy scipi and copy once we have those we can Define two variables the number of runs we want to complete and a reference bar for where we store our class label then in our main method we we can create an array of the size of runs which is 20 we'll use this array to store all of our classification error rates one every run then we'll write a for Loop to train our algorithm 20 times for each run we'll run a classification function which will attempt to classify a small sample set of images and store the error rate in the array then we'll print out the error rate to terminal and when we are done with all of our runs we'll go ahead and get the mean error rate from the array and print it out as the last statement in terminal so how does this classification step work before we answer that we need to understand these two methods load images points and modified house DP distance the load images points function loads an image file in our casee this will be a character image it then converts the image to an array and finds all the non-zero values that is all of the in pixels and stores that in an array then it creates an array of all the coordinates of those pixels and returns that the modified house DF distance is a metric that computes the similarity between two images by comparing their pixel coordinate arrays that comes from the load imagees points function it calculates the mean difference between both images and returns it the last parameter of the classification function cost just notifies a function that small values from the modified house dwarf distance mean more similar lastly let's take a at the classification function itself in this function we retrieve both our training and testing images and load their image Point matrices into memory then we compute the cost Matrix using the modified house DF distance after that we compute the error rate and return it that's all we do this for every run and then average them all and get the average error rate which isn't state-of-the-art like deep mind or BPL but it does make for a good Baseline demo of one shot learning one shot learning will only get more popular over time bunch of cool links down below check them out and please subscribe for more ml videos for now I've got to go fix an index out of bounds eror so thanks for watching

Original Description

Welcome to Fresh Machine Learning! This is my new course dedicated to making bleeding edge machine learning accessible to developers everywhere. The demo code for this video is a handwritten character classifier in Python using a One-Shot Learning technique with SciPy: https://github.com/llSourcell/One-Shot-Learning-Demo I created a Slack channel for us, sign up here: https://wizards.herokuapp.com/ I introduce two papers in this video Human Level Concept Learning through Probabilistic Program Induction: http://web.mit.edu/cocosci/Papers/Science-2015-Lake-1332-8.pdf and it's associated code is in MatLab: https://github.com/brendenlake/BPL but Matlab requires $ to download and Python is better suited for building production apps. I found a great alternative though, these guys are really close to finishing this python library. It's called 'PyBPL' they are working on making the results from the paper generalized so that you can apply BPL to any kind of example dataset. I talked with the lead dev and he said they'd have working demos out in 3-6 weeks so follow this repo!!: https://github.com/MaxwellRebo/PyBPL One-Shot Learning with Memory Augmented Neural Networks: https://arxiv.org/pdf/1605.06065v1.pdf and it's associated code is here: https://github.com/tristandeleu/ntm-one-shot Also, here's another very recent One Shot Learning Paper from DeepMind that I couldn't squeeze into this video but is very interesting: https://arxiv.org/pdf/1606.04080v1.pdf I love you guys! Thanks for watching my videos, I do it for you. I left my awesome job at Twilio and I'm doing this full time now. I recently created a Patreon page. If you like my videos, feel free to help support my effort here!: https://www.patreon.com/user?ty=h&u=3191693 Much more to come so please subscribe, like, and comment. Follow me: Twitter: https://twitter.com/sirajraval Facebook: https://www.facebook.com/sirajology Instagram: https://www.instagram.com/sirajraval/ Instagram: https://www.ins
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Siraj Raval · Siraj Raval · 24 of 60

1 What is Bitcoin?
What is Bitcoin?
Siraj Raval
2 5 Ways to Use Bitcoin
5 Ways to Use Bitcoin
Siraj Raval
3 BTC Fever - Siraj [Music Video]
BTC Fever - Siraj [Music Video]
Siraj Raval
4 5 Reasons to Build Decentralized Apps
5 Reasons to Build Decentralized Apps
Siraj Raval
5 The Interplanetary File System
The Interplanetary File System
Siraj Raval
6 How to Build a Dapp in 3 min
How to Build a Dapp in 3 min
Siraj Raval
7 Life Before Smartphones
Life Before Smartphones
Siraj Raval
8 4 Ways to Use Smart Contracts
4 Ways to Use Smart Contracts
Siraj Raval
9 3 Dapps You HAVE to See
3 Dapps You HAVE to See
Siraj Raval
10 Char's Life as a BitTorrent Engineer
Char's Life as a BitTorrent Engineer
Siraj Raval
11 4 Reasons AlphaGo is a Huge Deal
4 Reasons AlphaGo is a Huge Deal
Siraj Raval
12 Build a Neural Net in 4 Minutes
Build a Neural Net in 4 Minutes
Siraj Raval
13 Sentiment Analysis in 4 Minutes
Sentiment Analysis in 4 Minutes
Siraj Raval
14 The Hackathon Life
The Hackathon Life
Siraj Raval
15 Your First ML App - Machine Learning for Hackers #1
Your First ML App - Machine Learning for Hackers #1
Siraj Raval
16 Build an AI Composer - Machine Learning for Hackers #2
Build an AI Composer - Machine Learning for Hackers #2
Siraj Raval
17 Build a Game AI - Machine Learning for Hackers #3
Build a Game AI - Machine Learning for Hackers #3
Siraj Raval
18 Build a Movie Recommender - Machine Learning for Hackers #4
Build a Movie Recommender - Machine Learning for Hackers #4
Siraj Raval
19 Build an AI Artist - Machine Learning for Hackers #5
Build an AI Artist - Machine Learning for Hackers #5
Siraj Raval
20 Build a Chatbot - ML for Hackers #6
Build a Chatbot - ML for Hackers #6
Siraj Raval
21 Build an AI Reader - Machine Learning for Hackers #7
Build an AI Reader - Machine Learning for Hackers #7
Siraj Raval
22 Build an AI Writer - Machine Learning for Hackers #8
Build an AI Writer - Machine Learning for Hackers #8
Siraj Raval
23 Build a Chatbot w/ an API - ML for Hackers #9
Build a Chatbot w/ an API - ML for Hackers #9
Siraj Raval
One-Shot Learning - Fresh Machine Learning #1
One-Shot Learning - Fresh Machine Learning #1
Siraj Raval
25 Generative Adversarial Nets - Fresh Machine Learning #2
Generative Adversarial Nets - Fresh Machine Learning #2
Siraj Raval
26 Tone Analysis - Fresh Machine Learning #3
Tone Analysis - Fresh Machine Learning #3
Siraj Raval
27 Generate Rap Lyrics - Fresh Machine Learning #4
Generate Rap Lyrics - Fresh Machine Learning #4
Siraj Raval
28 Build an Autoencoder in 5 Min - Fresh Machine Learning #5
Build an Autoencoder in 5 Min - Fresh Machine Learning #5
Siraj Raval
29 Build a Self Driving Car in 5 Min - Fresh Machine Learning #6
Build a Self Driving Car in 5 Min - Fresh Machine Learning #6
Siraj Raval
30 Build an Antivirus in 5 Min - Fresh Machine Learning #7
Build an Antivirus in 5 Min - Fresh Machine Learning #7
Siraj Raval
31 TensorFlow in 5 Minutes (tutorial)
TensorFlow in 5 Minutes (tutorial)
Siraj Raval
32 Build a Recurrent Neural Net in 5 Min
Build a Recurrent Neural Net in 5 Min
Siraj Raval
33 Build a Simulation in 5 Min
Build a Simulation in 5 Min
Siraj Raval
34 Build a TensorFlow Image Classifier in 5 Min
Build a TensorFlow Image Classifier in 5 Min
Siraj Raval
35 Tensorboard Explained in 5 Min
Tensorboard Explained in 5 Min
Siraj Raval
36 Generate Music in TensorFlow
Generate Music in TensorFlow
Siraj Raval
37 Build a Game Bot (LIVE)
Build a Game Bot (LIVE)
Siraj Raval
38 Deep Learning Frameworks Compared
Deep Learning Frameworks Compared
Siraj Raval
39 Introduction - Learn Python for Data Science #1
Introduction - Learn Python for Data Science #1
Siraj Raval
40 Build a Neural Network (LIVE)
Build a Neural Network (LIVE)
Siraj Raval
41 Twitter Sentiment Analysis - Learn Python for Data Science #2
Twitter Sentiment Analysis - Learn Python for Data Science #2
Siraj Raval
42 Recommendation Systems - Learn Python for Data Science #3
Recommendation Systems - Learn Python for Data Science #3
Siraj Raval
43 Predicting Stock Prices - Learn Python for Data Science #4
Predicting Stock Prices - Learn Python for Data Science #4
Siraj Raval
44 Pong Neural Network (LIVE)
Pong Neural Network (LIVE)
Siraj Raval
45 Deep Dream in TensorFlow - Learn Python for Data Science #5
Deep Dream in TensorFlow - Learn Python for Data Science #5
Siraj Raval
46 Visualizing Data with D3.js (LIVE)
Visualizing Data with D3.js (LIVE)
Siraj Raval
47 Genetic Algorithms - Learn Python for Data Science #6
Genetic Algorithms - Learn Python for Data Science #6
Siraj Raval
48 Enter Siraj [Music Video]
Enter Siraj [Music Video]
Siraj Raval
49 Build a Web Scraper (LIVE)
Build a Web Scraper (LIVE)
Siraj Raval
50 Why is P vs NP Important?
Why is P vs NP Important?
Siraj Raval
51 How to Make a Neural Network (LIVE)
How to Make a Neural Network (LIVE)
Siraj Raval
52 How to Make an Amazing Tensorflow Chatbot Easily
How to Make an Amazing Tensorflow Chatbot Easily
Siraj Raval
53 How to Make an Amazing Video Game Bot Easily
How to Make an Amazing Video Game Bot Easily
Siraj Raval
54 How to Make a Tensorflow Neural Network (LIVE)
How to Make a Tensorflow Neural Network (LIVE)
Siraj Raval
55 How to Make a Simple Tensorflow Speech Recognizer
How to Make a Simple Tensorflow Speech Recognizer
Siraj Raval
56 Joel Shor - Really Quick Questions with an Awesome Google Engineer
Joel Shor - Really Quick Questions with an Awesome Google Engineer
Siraj Raval
57 How to Make a Path Planning Algorithm Easily (LIVE)
How to Make a Path Planning Algorithm Easily (LIVE)
Siraj Raval
58 The Best Way to Prepare a Dataset Easily
The Best Way to Prepare a Dataset Easily
Siraj Raval
59 Catherine Olsson - Really Quick Questions with an OpenAI Engineer
Catherine Olsson - Really Quick Questions with an OpenAI Engineer
Siraj Raval
60 How to Make a Tic Tac Toe Neural Network Easily (LIVE)
How to Make a Tic Tac Toe Neural Network Easily (LIVE)
Siraj Raval

The video teaches One-Shot Learning using a handwritten character classifier in Python with SciPy, demonstrating how to learn with few examples and its potential applications.

Key Takeaways
  1. Import necessary libraries
  2. Define variables for runs and class labels
  3. Create an array to store classification error rates
  4. Train the algorithm 20 times
  5. Compute the error rate for each run
  6. Print the average error rate
💡 One-Shot Learning can be achieved using different methodologies, including Baysian Program Learning and Memory Augmented Neural Networks.

Related Reads

📰
CentryAI
Learn how CentryAI simplifies machine learning model development and deployment with its no-code platform and microservices architecture
Dev.to AI
📰
# Engineering Log #03 — The honest asterisk got cashed in (product F1 0.887), and the model finally became a product
Learn how to engineer and deploy a model to become a product, achieving a high F1 score of 0.887, and understand the importance of model development and testing in the engineering process
Dev.to · yubin hong
📰
Part-05 Performance Tuning & Optimization: The Production Secret Sauce
Optimize Spark jobs for better performance by identifying bottlenecks and applying targeted tweaks
Medium · Python
📰
AI Bisa Membantu Forecasting Penjualan, Ini Cara Menggunakannya
Learn how AI can improve sales forecasting and reduce errors, crucial for business success
Medium · Machine Learning
Up next
Dropout in Deep Learning
AnuTech-CH
Watch →