hello welcome to a new video series in
this video series I'm going to build
something that thing is going to be a
doodle classifier in other words you
might be familiar with something called
M nest you might have heard of M nest
it's the m-miss database of handwritten
digits this is a very famous classic
hello world if you will a data set for
machine learning to test an algorithm to
see how it works even to teach about
machine learning it is it is divided
into training and test data I will talk
about that during the course of these
videos but it is a database of
handwritten digits here is a and you can
see it if I if I say no loop here in the
console really quickly you can see there
is a zero it is labeled in the database
as a zero now what I have over here is
my beautiful drawing of a wonderful
kitty cat which by the way my example of
trying to guess what digit that kitty
cat is it guessed it as a two so what I
want to do in this series you could find
my emne stemple it's not in a video
series but it's there in the github
repository is I want to build from the
very beginning a inist style classifier
but instead of classifying digits i want
to classify doodles so i want to know is
that a cat you drew or a puppy or a
rainbow or something else and how am I
going to do this I am going to do this
with the Google quick-draw data set up
so quick draw is a project I believe
from Google creative labs and let's just
play it for a second let's draw draw an
octagon in under 20 seconds oh my god 1
2 3 4 5 ok and this is way too stressful
for me and it started talking to me I
know if you could hear that I don't got
it I don't got it so this is a game that
you can play
as you play it a machine learning system
tries to guess what you're drawing and
it just so happens that let me find
quick draw data set I don't know what
I'm looking for here well that I already
have that sorry ah quick draw did it
just so happens that people playing this
game
Google collected 50 million drawings
across 345 different categories and all
of that data is available to you and in
fact this is what I'm looking for I
could go to you could and I could browse
the drawings here so I could say like
let me look at all of the cellos and you
can see these are millions and millions
of different cellos that people have
drawn and I have access to all this data
now what's really interesting is that in
addition to just having the image itself
you're like oh look I can see it on my
screen the system saved the vector path
of the drawing itself so there's a lot
that you could do with it in thinking
about this sequence of how it's drawn
and that's something I hope to get to at
some point in a future video but in this
example I am going to treat these as
little bit mapped images I'm just gonna
use a little snapshot of each drawing
that's going to be the data associated
with a given classification also known
as label or class this is a 28 by 28
pixel cello now this is not my own
genius idea because I don't have any of
those definitely not M NIST Google
quick-draw this idea came from this blog
post by Rajiv Shah using Google's
quick-draw to create an amnesty dataset
you can follow along and there's
information about how to do this all of
this is looking at how to do this in
Python I believe I don't know if it then
goes on to use tensorflow or what or if
it's just actually showing you how to
get the data but I'm going to sort of do
this on my own and I'm gonna use
processing and - to parse and work with
the data and p5.js to then do the neural
network magic stuff okay are you with me
are you gonna watch this so the first
video this is like my introduction to
the ID
and in the next video I'm going to start
working with the data but let's do let's
ghost go a little further by way of
introduction so how is this going to
work and so one thing I want to mention
is that I already have the I'm going to
be able to do this because I have built
something and there's a whole video
series that you can watch where I build
it's about 10 or so like 18 videos long
toy neural network this is a JavaScript
implementation of a simple neural
network now eventually if in the great
future beyond when you're watching this
in the year 7,500 from your gelatinous
tube I will hopefully have also
completed this same demonstration or
similar demonstrations using something
called ml 5 which is built on top of
something called deep learn is so deep
learning is is a project also from a
Google research group which is an
implementation of deep learning in the
browser hardware accelerated with the
GPU doesn't that sound fancy so
basically it's a highly optimized way of
doing a lot of stuff where we have
really big data sets and you need to do
stuff faster in a more robust fashion
for me right now I want to demonstrate
the core concepts and using this sort of
like simple toy library is not gonna
produce them quote unquote best results
but I'm hoping it reduces the best
results for learning at this point and
we can I'm gonna get to this stuff after
that ok that's number one
so assuming I have that that means I
don't have to in the course of these
videos write the code for the so-called
neural network the neural network is
going to be the thing that sits in the
middle something has to go into it some
set of input something has to come out
of it some set of output I should say
that to do machine learning in the sense
of like here's some data please
do something with this analyze this data
for me do some math with it and then
give me some information about it back a
neural network is not the only thing
that can sit in between
input and output and you might have seen
other videos that I've done about you
know K nearest neighbor there's things
like support vector machines decision
trees there are lots of other machine
learning algorithms through this for
this case for this learning process and
for some of the other examples where
neural networks perform really well that
I hope to get to that's what's sitting
in here so what I need if I have that
already from my library what I need is
to figure out what are my inputs and
what are my outputs in this case my
input is going to be I am going to use a
28 by 28 pixel image maybe it is said
doodle of a cat right and that is going
to be my input into the system now if
you've watched my previous videos what
you'll typically see and this will
change as we get to more sophisticated
machine learning architectures in
particular I just want to like
foreshadow this something called a
convolutional network which is really
designed to work with images I'm not
doing that yet this needs to be
flattened and it needs to be flattened
into what's often referred to as a
vector or a one column matrix so I need
to take this data it's an image and
convert it to a list of numbers this is
this is the what this is probably in
many ways the most important thing that
you need to do when you're working with
machine learning is like what is my data
how do I format it and and there's lots
of other questions about it as well so
well I'm gonna come to that but let's
just thinking about this this is a
pretty this there's a way that I can do
this I'm not saying it's the
quote/unquote best way but there's it
certainly a simple way each one of these
pixels has a brightness value that
brightness value is somewhere between 0
and 255
I can normalize it because it helps to
have your inputs have kind of a smaller
range of lobe numbers I could normalize
that by dividing by 255 to range from 0
to 1 and then now 28 by 28 is 786 a 784
pixels
I now have you know
one you know point seven point six so
this will become my inputs I need to
look at the images I need to convert it
into an array of floating point numbers
normalized between zero and one and that
becomes the input to the neural network
system and if you look at the neural
network library it's actually that's
what it's asking you to pass into a
train function or a predict function
give me an array of numbers
alright so wouldn't just take a pause
here for a second
and I want to get to the outputs but
before I do that something really there
something really important here so while
the purpose of these video tutorials
that you're watching that I'm making is
probably primarily the learning process
what I mean by that is your learning
process and I'm just creating a kind of
arbitrary scenario that's somewhat
interesting to see if how this stuff
works really if you really if you're
working with machine learning these
systems it's really important for you to
ask yourself should I be doing what I'm
doing is what I'm doing ethical am i
hurting someone did I what is this data
set that I'm using what's missing in the
data set so we think about it this we
could say okay well I'm just building a
doodle classifier you know what's the
worst thing that's gonna happen but I
think as a useful exercise to yourself
you might think about who is not rep
what is not represented in that doodle
data set so I would love to come back to
this as a topic about how to collect
data and think about data and bias and
algorithms in a more substantive way I
will just take a moment to point you to
the research of Mimi on ooh aw oh ha who
runs a project called missing data sets
and I encourage you to check out her
website and a lot of her work around
missing data and ways and people are
abstracted represented and classified so
that said let me come back now to the
next piece output so if our input is
pixels and we've taken all of those
brightness values and normalize them to
zero through one we now need an output
now here's the thing what am i trying to
do in the case of the handwritten digits
I'm trying to say is it a zero is it a 1
is it a - is it a 3
blah-blah-blah-blah-blah
in this case I'm trying to say the kitty
cat this is a rainbow is it to you
or is it a cupcake all these wonderful
things is it a heart baby it'll be some
hearts on it so let's just say I'm going
we have to make a decision here let's
just say I'm only going to use three
kinds of doodles in that case my outputs
what I want is also a vector a one
column matrix a list of numbers and I
want those numbers to represent the
probability that this particular image
is any one of those given categories for
example if it's if it's a kitty cat
instead of a rainbow or a cupcake maybe
I want it to give me that output if it
is a rainbow maybe I want it to give me
this output if it is a cupcake maybe I
want it to give me that output in
reality we're probably going to see
something that looks when the when the
neural network itself is guessing we're
gonna see something that looks more like
you know a point eight point one point
one and in theory we want all of these
to add up to 100% now the first time I
do this as I begin it's probably not
going to do that but at some point
towards the very end of this playlist
I'm gonna get to something called
softmax which is an algorithm for
guaranteeing that the output of a neural
network everything adds up to 100%
probability so we'll come back to that
at some point okay this is the main idea
and so what we have going on here is a
supervised learning process and by that
I mean we have this data set it is
labeled I have the data from Google I
have all those drawings so I'm going to
give the neural network I'm gonna say
here's a drawing of a kitty cat I expect
you to say to me 1 0 0 if you give me an
incorrect answer I am going to ask you
to adjust all your little parameters
inside of you little parameters weights
and things
inside of your neural network and try
again we're gonna do this over and over
and over again that's supervised
learning
here's known data here's known data
here's known data we've got to do that
for quite a while before we are ready to
then say now I'm gonna draw my own kitty
cat for you what do you think neural
network do you like it so that's the
idea but there's an important piece of
this when I go to get the data one thing
that I want to do is that I want to make
sure that in addition to training data
let's say I take 1,000 kitty cat
drawings I want to save some amount of
it you know maybe a typical amount it
might save is 20% so I might save 200 of
those drawings and only use 800 in the
training process and save 200 of them
for testing
meaning how can I know whether my
machine learning algorithm is working
well well if I just test it to see if
it's getting the right answers for the
drawings I've trained it with I might be
stuck with something called overfitting
overfitting refers to when almost like
the neural networks is doing such a good
job
it's trained itself so well that it's so
highly optimized in tune to the stuff
that you're trained it with that it
can't really deal with stuff that it's
not trained with and that's thing we
have to watch out for now there are
techniques to fight against that I'm
something I'm going to come back to in
another videos like something called
dropout and there's more and more things
but one way we can at least sort of test
ourselves that we're hopefully not
overfitting is by running data that it
wasn't trained on and seeing how will it
perform how many do I get correct out of
those 200 after I've trained it so this
is what why I need to do so that's by
way of introduction then the next video
what I'm going to do is download a bunch
of drawings prepare them and get them
ready because it's work by the way
preparing cleaning normalizing thinking
about your data is just as a big is a
project unto itself right machine
learning isn't just some magic that you
do and you just say sprinkle the data on
it and now I'm done you've really got to
be thoughtful about that data and so
I mean hopefully hopefully I will be
somewhat thoughtful about the data in
the next video
okay see you soon
[Music]
you