[Music]
Sound Check 1 2 3 how's my audio
everybody
[Music]
good morning happy Saturday it's like
this like the old days in Saturday
morning when everyone would wake up and
gather around the television tube not
the youtube and watch cartoons and now
you're all here gathered around the
YouTube and watching the coding trade
it's very weird to be here on a Saturday
especially in the morning I don't think
I've ever struck I probably streamed on
a Saturday before I don't know that i've
streamed on a Saturday morning before
this isn't a particularly great time I
mean there's something about this time
it's actually quite nice I feel sort of
relaxed in a bit at ease
and kind of very glad to be here but
also you know the weekend is the weekend
and there's lots of family stuff and
other things going on so I don't know
that I'll be making a habit of this but
here we are nonetheless welcome it's so
nice to see so many people here I don't
actually see you but I feel your
presence I feel more calm today for some
strange reason maybe it's because I read
the marathon last weekend and and I have
a very particular topic that I want to
focus on today just quickly before I go
that topic I want to just thank the
sponsors today for Saturday's coding
train livestream which are - Lane and
Linode so if you go to - Lane comm slash
coding train or Leno dot-com slash
coding train you can find out about both
of these web services - Lane 4 as a
password manager and Lou node as a cloud
server and I'll come back in the middle
of the livestream and talk to you a bit
more about the sponsors and show you
some clips and things features that they
have and tell you about the coupon codes
okay so the console.log hello world says
Cybertron hello
Cybertron it is but still a bit low and
Nathan in the chat is way so nathan is a
very loyal viewer who has
really been getting at me to do some
upgrading of the audio equipment that I
have is actually quite good I believe I
have a lav mic here actually have a
shotgun mic over there that I don't use
but what I really need to do is some
fine-tuning of the audio there I use a
piece of software called open broadcast
studio we actually check I don't believe
I'm recording anything to disk right now
I'm gonna add that it's right here I'm
gonna hit start recording and the focus
is also down a point you know I I'm out
of I'm not of practice here it's
Saturday morning and I'm just like
what's going on I should be at home
having brunch and putting my reading a
nice magazine or book and listening to
some jazz music on the radio I'm gonna
use this not a sponsor but favorite one
of my favorite products called the elko
stream deck which is by tool for
focusing because I put it over there and
then I walk over to the camera and I
focus on it there we go I think that's
problem is my eyesight it's actually
quite bad so I can't even see good
enough I think that's better
alright so one thing I want to mention
today if you have been paying attention
to the coding terrain YouTube channel
you would be aware of this but if you're
not if you go to the coding train comm
/tm for teachable machine will take you
to a web page which has three videos
that I actually two videos that I
released this week and one that's still
sitting on the channel as unlisted other
people are asking for the audio to be a
little bit louder I'm always afraid to
turn it up because I'm just worried
about it peaking but everybody is
telling me that it could be louder so
let's let me go I have a little dial
here's this little dial I see it here
it's call
it says gain on it it's on this audio
interface it's blinking green and if I
just turn it a little bit to the right
I have now made myself a little bit
louder I think and I see it's in the
yellow but not in the red the problem is
like it's very excited sometimes going
into the red but a teachable machine is
a project from Google Creative Lab that
I referred to in a lot of my ml 5 je s
videos and but they released a new
version of it if I go to teachable
machine with google.com I will be on
this webpage and it is a fast and easy
way to create machine learning models
for your sites apps and more no
expertise or coding required and you can
see that so base I'm not going to go
through this right now because I have
three videos that go through it in quite
a bit of detail but I encourage you to
check out the video about it there they
actually have their own tutorials that
you can watch that are much more
succinct and it's like insane as mine so
I don't know what your preference is but
if you just want to learn how it works I
would definitely recommend you watch
theirs instead of mine if you want to
watch somebody embarrass themselves for
15 or 20 minutes then you can watch mine
there's some wonderful projects and what
I what I'm excited one things I'm very
excited about is how they've integrated
the teachable machine machine learning
models with all these other libraries
and frameworks in particular the p5.js
library with the ml5 library so I don't
want to go through this now it really
relates to what I do want to do in this
session which is a look at a particular
feature of the ml 5 library that it also
deals with training a model but I would
encourage you to check out my videos and
in particular I would really love to see
what people make with this I mean I love
that for everything but I'm particularly
curious as to whether this method
Oh G of working this interface in the
browser that allows you to train a model
and then download that model or export
or upload that model to work with say
p5.js and ml5 if that's something that
inspires people to make creative work
and so for all any of these videos if
you click on this to the tutorial button
and there's actually the one of them has
you'll see there's this area called
community contributions and I want to
see your community contributions here so
badly so please and because I would like
to come back and look at some of them
and play with them on a future video
there was one so I think if I go to them
maybe the snake game yes so Mika crucial
who has been a wonderful supporter of
the channel in contributions on github
thank you so much for you adding a lot
of stuff to the website and things that
I really appreciate that if this is the
only community contribution that I know
of so let's try it and what's one of the
things that's really interesting about
this system is if you train the models
say using your webcam it's going to
learn the context of what your webcam is
looking at so let's say you train it to
recognize a banana versus an orange
would that still work when I look at it
here in this context with the green
screen behind me all right so I am Here
I am loading there we go so I think the
idea here is that I'm supposed to play
rock-paper-scissors with the computer
hmm I guess the computer is just winning
oh no I want I guess it's actually
detecting that I did scissors or I'm
gonna do paper it detected my paper
that's awesome of course I lost paper
again I win let's see you does it detect
rock
there we go thinks that scissors thinks
that's paper so what a couple things I
would say here is that interaction
design wise just as a little critique
here I'm kind of confused so what I
think I understand is that's what the
computer is picking and that's what I'm
picking but what I'm but what I'm really
confused here is about the timing so I
feel there's this like ready but I feel
like what might be helpful is some sort
of like countdown timer like get into
position you know because when you play
it one way to play the game is rock
paper scissors or says shoot like that
kind of thing so I wonder if there's
some kind of way that it could step me
through the process a bit more and maybe
the visual language of this being bigger
is meaningful and the I could be emojis
is like what's the computer versus me or
also I think quite effective
but something about the difference in
sizes and the placement I like that the
video is there but kind of faded into
the background that's kind of I think a
nice idea but I think there may be there
could be some other ways to think about
how to do the interface I also am really
lost in finding myself because I think
this is cropped and I would I would
always I would mirror the video because
it just makes interacting with things
much easier because oh no it is mirrored
it is mirrored it's definitely mirrored
I just was oh I see maybe it's doing
that on purpose so that if I put so that
there we go I see this is what it wants
me to do so maybe there could be it
could there could be a bit of a stage
where it lets you kind of get set and it
seems there's a moment also where it's
like freezing and not that's find that
very distracting so I kind of want to
see it always great so I want to see
more of these Oh me cos in the chat the
timer is the pink bar at the top okay
got it
I see I see
ah and Simon is saying that there have
been a bunch of community contributions
from the interactive drawing video so
maybe I will
let's let's go let's go take a quick
peek at that
Oh one thing I need to do so I have this
iPad here where I can play and the cold
left conjecture okay okay everybody
settle down settle down
it only has 2% battery left so I'm going
to unplug over here so I won't have any
music for a little while let me let this
charge up but it'll charge up by
hopefully the time that I need that
music all right let's check out what
else is happening on the channel here
there's the interactive drawing was one
of our recent video that I can take a
look at and also the koloff's conjecture
I haven't had the time to do another one
of these Cabana videos which I'm very
sad about ironically I probably would
have done one this morning but what's
been coming here to do this live stream
but too many things to do okay
I don't see any community contributions
for this one yet I'm shocked I'm shocked
I'm shocked after community contribution
for this video let's check out the
coalesced conjecture they definitely
have been a bunch whoa there's a lot
amazing let me just do a quick click
through I'm just gonna open them all up
this one for some reason doesn't have a
link let's let's open that this is
probably a bad idea what I'm doing
let's let's just let's just look through
these okay of course
mwah little rainbow koloff's conjecture
visualization got to love that this is
by a sequential chaos now we've got one
that is by Alvaro ko looks pretty
similar to mine but there's probably
something different here that I'm not
aware of let's see if it says growing
visualization oh no no if this this is
not similar than mine I made a version
of this like this myself just to make a
gif to post on Twitter but this one is
actually animating it I forgot that my
video tutorial doesn't animate it so
that's wonderful thank you for that
um koloff's tree refresh Oh sad where's
the tree
[Music]
why is it showing me all this nonsense
okay so I'm not sure what's happening
with this one we can click on looking at
the code and try running it here so I
have to click I probably have to click
or something nope
so I'm not sure what's going on here
Donna we let me know I'm happy to try
showing it again this is a coal lots
visualization from a spectral flame
added code for animated and static
drawing so one thing I certainly
recommend if you can let's see is to add
a readme file with like a gif animation
or a screen shot that scroll down the
page says Simon let me go back to that
one the coal Lots growing tree okay
let's go back to uh it was just it was
just taking up a lot of space there it
is another growing one and I like the
color selection here the green this is a
good team trees if you have a major team
trees donation please go ahead and do
that oh here's a really night look at
this one I like this from super Rimbaud
this is kholat sunray sun sunrise from
anuraag Hazra this is quite lovely this
was I saw this on Twitter and a lot of
people had sort of fun names for this
kind of supernovae I like design and I
like this use of dat GUI here looks like
I could probably try changing various
parameters and I don't know if oh and
then if I click I guess it will it'll
it'll every time I click it'll reset and
rerun with these new parameters I really
want to do some more prints printing of
these and make some so that's our
plotter stuff I kind of come back to
that today this is lovely okay
Kolak Swede this is interesting
again another processing one there's
this now I really want to kind of run
this so I've tried like I guess I guess
to run one that's in processing I have
to just download it and now if I'm gonna
do this I should also go back to
spectral flames because it's only fair a
lot of stuff in this downloads directory
but since there's a fish I got to know
what this fish is oh look at that I love
this so I love this I think what I love
about this which surprises me in a way
is using I suppose this Co Lots
conjecture visualization in scene so you
could imagine this being a 2-d game that
you're playing whether you're moving of
drop bump you know what you're the fish
and you're controlling the fish and the
fish has to eat or swim or whatever but
well the while those you know the trees
at the seaweed at the bottom was all
coming from the coal lots conjecture
okay let's Oh Kolak my seat REE
I guess so this looks like maybe it just
picks a different angle and a color
skiing each time which is really really
nice so nice to see these on these
variations another rainbow one Thank You
Louis still a all and we're seeing this
also on code pen so it's nice to see
people try different code editors and
frameworks Eric rovol it posted
something about trying a 60-degree angle
and it looks like the image I'm seeing
over here on my slack chat screen is
showing a very like hexagonal pattern
which is nice I don't know if that's
gonna show up another one here garrulous
- bye Diplo focus oh wait I think I made
everything tiny there we go whoo I like
this I like I like this idea of these
sort of like - lines here
spectral flame we're going to try that
let's try spectral flame
let's cure this here up let's get rid of
this here and
try this nope that's the other one not
this one there we go
ooh I like this I like the layering of
this now what's different I guess it's
doing huge sections at once and then
varying the color and kind of blending
it it's quite oh wow this is quite
enjoyable needs some use this needs full
screen in music I just let you enjoy
this for a minute
oh I still have my mic on I thought I'd
muted my mic I was thinking a break
there give myself a break
so does immunity my mic probably her me
some tea over there okay I'm back
hello this is lovely ah beautiful just
beautiful okay
refresh the repo oh look at this here's
a nice read me
I'm solicited okay the version of
numberphile uses the angle of pi divided
by 13 to the right and pi divided by 20
to the left they have these long lines
with bumps on the underside of them okay
I think if I'm right spectral flame
maybe you also commented in the actual
YouTube video somebody wrote a really
excellent commentary about somewhere
that I did read it was on Twitter or in
the YouTube video or maybe it was oh
maybe this was the conversation we had
on github but and maybe it was spectral
flame apologies if it was somebody else
who really did it sort of deep dive in
figuring out what were the properties of
the visualization from the numberphile
video and how those were different from
the ones that I that the version that I
created and it looks like there's a
really nice explanation of that here and
played around with some more and got
this colorful artwork and equals it so
it's hard to read five million change
the color plow to include all colors Wow
look at that that is quite something
technique Collins is asking where can I
get the documentation for the quick-draw
project so I'm not sure exactly what
you're referring to but if you're
referring to the actual quick-draw
dataset that is also from Google
Creative Lab and there's a github repo
that has all of the documentation of the
quick-draw dataset if you're looking for
information related to my video tutorial
that makes use of a
machine learning model called sketch RNN
which was trained on the quick-draw
dataset then you can find that at the
coding train comm if I go to this the
challenge page and typically I mean
sometimes things are missing here and if
they are you can file an issue or
actually submit the link but all of the
relevant links related to the material
that I use should show up here other
videos that are related to show up here
and then community contributions but if
you're looking for the code you can find
that here and a lot of time my goal is
to always have JavaScript code
processing code and a link to the
version running in the web editor but
this one has no processing code because
I don't currently have a Java
I didn't there's not an easy way to
bring the sketch RNN model into Java
I'm definitely possible but it's not
something that I've spent some time
doing
I added this overlay thing I know there
haven't been any new members or anything
joining yet I'm just curious if
something's gonna pop up will it Cody
train will ask DT six will you try Q
learning in the near future so I would
answer yes to that question if we could
take the word near out it's really it's
a little bit's I'm having a tough time
I'm just definitely doing a lot and
making content and I made this list I
definitely don't have it Simon probably
has it handy somewhere at the beginning
of the semester of kind of the things
that I wanted to do this semester I've
gotten to very few of them I haven't
gotten to some of them but I got a very
few of them a q-learning is on my list
of things that I would like to tackle
it's not something that I have a lot of
experience with a researcher here at NYU
named Aiden Nelson has made a bunch of
q-learning examples with p5 I can try to
find those and and and Link those
contain well they look like that overlay
works I would have to refund you your
money thank you oh oh that's sad what do
what I need to do to get that to work
well
there we go thanks Simon is now sharing
with you me on my list
I wonder if there's an easy way for me
to pull that up on screen but and Dan
man asks are you going to make videos
about our making our personal teachable
machine framework ah okay we will let me
cover this and then some people are
asking about whether the teacher low
machine sorry this was not a call to ask
people to give super chats I apologize I
didn't I was not really my intention
thank you very generous of you and it's
very much appreciated and I thought I
had a little overlay they thought people
thumbs up for their messages but
apparently that didn't work so I forgot
about the questions let me this o it so
many good questions I'm trying to try to
try to answer these
okay I'm gonna I'm gonna actually scroll
the chat which will stop it
automatically scrolling okay are you
going to make videos about making our
personal teachable machine framework so
so I actually have well look at all what
an interesting that this pops up this
weird what I'm looking for is the
YouTube playlist but it's kind of
interesting I guess from the ML this
this is what this is the link I'm
looking for us apologies oh I want the
playlist though oh the Internet is a
rough place why don't I have this
playlist linked in an obvious place
let's try with the chances on like one
of these probably not
website working on the website
[Music]
ah an issue to github so I can pull up
thank you that's an excellent way of
doing this I have a lot of content but I
guess I have to go do I have to do what
I didn't want to do which is actually
just go to my channel how are there 447
people watching this right now and look
for playlists oh my god you know it's
bad when I can't even look at this
private liked videos mmm I want that to
show up I'm naughty I need anything else
oh I'm logged into my like main account
it's not my intention oh oh god this is
this is not going well
created playlists what I'm looking for
is it's gonna happen for me
the question was are you going to make
videos about making our own personal
teachable oisin framework if you want to
do that you can do that with the
discussion in my ml 5 video about
transfer learning with the feature
extractor and then running your own
feature extractor classification example
this is basically a bit more that's that
in terms of the tactical material that
you would need to actually create the
training interface and control the
training process yourself more closely
so sorry that took me a long time to
pull that up and what I want to do today
is actually add make content to go
through a bunch of examples in this live
session that will get edited it down
into videos that will end up in this
playlist about training a neural network
model all right so the other questions
were the teachable machine experts are
currently broken is that being looked
into I don't know I do know that there
is a sort a little bit of a source of
confusion a bunch of people posted that
they had an error like a fetch error and
maybe I can just touch on that really
briefly
so if I were let's just pretend for a
second that I just trained a model and I
went here to export model there's no
model train so you're going to get once
you've gone through this whole process
you're going to get a URL that's here
and then you're going to see here you're
also going to see a code snippet what's
confusing is the URL that teachable
machine gives you does not include it's
just the path to the all the model file
excuse me but it does not include model
JSON which ml5 expects so if you were
copying and pasting yeah thanks thanks I
can I can tell if you're copying and
pasting this code the URL that you have
for the model that gets stored in a
variable and then you have to append
modeled up JSON for it I was seeing
people have that error there is a
YouTube problem with emotes on streams
spamming like 10 emotes can get your
Google account suspended alright so
those were some questions that I wanted
to answer I think I better get started
with some content it's already 11
o'clock and I'm going to do my sponsor
segment at around 10:30 11:30 you know
travel back in time so someone keep me
on track here and I think this is gonna
go until 12:00 or 12:30 I mean at this
point most likely 12:30 okay how's that
let me see how my oh and let's go to the
let's since I asked for it let's pull up
what github.com slash website what is
wrong with me coding train slash web
site issues and to-do list okay oh wow
let's just take it let's do a little
accounting here uh RDP done Mauro's done
colas conjecture
tick tock nope nope none of these none
of these done we could add by the way
team trees edited version I don't know
if it makes sense to edit that into
something that's sort of a discussion
avid Mattia ah so this is what I'm going
to do today
excellent I sort of did this I sort of
did this but I chain of drew making the
video tutorial we discovered a lot of
problems with library to change so I
need to redo this tutorial I did this I
haven't done any of these I'm done any
of these hoc tober festers over
streaming improvements nightbot it says
Nike bot this should say nightbot I
believe discord and then 2020 so this is
stuff for 2020 okay all right so this is
good I'm not doing terribly the latent
space stuff I'm really excited to do
with runway ml so I have some plans for
that this I definitely want to do this
is a collaboration with a youtube
channel called practical engineering so
I need to get back to practical
engineering about that and today's topic
will be this I don't think there'll be a
coding challenge today I'm looking at
this but today I think today this is
today ml 5 neural network ok so let me
let's see how my the charge is going
with this
6% boy that really didn't do very good I
guess I could try to get it keep it
plugged in I have anything that this
could connect to not really there's no
plug
[Music]
just looking at my notes from my class
Singh where
[Music]
okay I think I'm gonna do this stuff so
in case you're wondering what I'm
looking at I'm teaching a course at NYU
this semester called introduction to
machine learning for the arts and I've
been preparing a lot of material and
doing a lot of teaching in the course
about it I haven't been able to keep up
my plan was to be making the videos for
the course all semester long and yeah
and to some extent I've been doing that
but I got way behind so I'm kind of
going back to remind myself what I did
in class and sort of deciding how to how
that is going to feed into what I want
to show in this particular set of videos
and so I think I think I'm ready to go
and the other thing I want to do well
I've up one upgrade I've made to my
recording a system is that I have a way
and I'm about to turn this on of
recording all the different feeds to
disk separately green-screen
the laptop screen and the whiteboard and
so this if I'm going to edit if when I
say I
if matsya who does the is the video
editor for the coding train is going to
edit all this stuff together it's
actually really helpful to have all
these separate things in case we want to
like add some more content and fix them
things up okay so I'm just looking in
this set that so I should so I need to
record output shoot sorry give me a
second here apologies to everyone that
I'm doing this during the stream but
okay so output two is the whiteboard
output three is the green screen output
4 is the laptop and so if I go to my
multi quarter and I say I want two three
and four
now I'm gonna start recording and I'm
recording everything okay all right so
I'm trying to think of how I want to go
about this as the nice thing vote so
this is good and bad the good news is I
have more possibilities for creating
higher-quality edited versions of the
livestream later because I now have the
capability to even if I'm showing you
things and talking about stuff during
the livestream I can replace the
background with different content or
more zoomed in and highlighted content
or even like other animations and other
things so I could mention something not
even show it and then show it later so
that's the good news the bad news for
you is that I don't want to fall in the
trap of then just not ever showing
anything in the live stream and I don't
want to also make the process of editing
and putting together the videos so
onerous that it becomes so slow I'm also
like getting a lot of feedback from my
monitor so let me just mute this okay
great okay so what I'm going to talk
about today is and the ml5 neural
network class
hello and welcome to another beginner's
guide to machine learning with ml5 jazz
video in this video I am going to look
at a piece of functionality in the ml 5
library called it just heard a weird
noise outside the room I also hate that
this light reflects in my glasses I hear
by the way I don't have any buddies from
the film industry but I hear that often
actors or performers in films will get
these special non-reflective like lenses
glasses because this is a common issue
obviously if I had the lights above me
or something
that could also get around this issue or
but so is that a thing cuz I'll go and
buy those you could go get new I need
new glasses anyway I need a new
prescription Oh
spectral piano is off I suppose ok
whirly noise I really want to do that
whirling noise stuff also should add to
this list the not tomorrow's the other
the star roads maybe okay hello and
welcome to another beginner's guide to
machine learning video tutorial with ml
5 yes very excited about this one
typically excited about the video just
like me but this one I'm particularly
excited about because I'm gonna look at
something that has recently arrived in
the ml 5 jazz library so first of all
used version zero point four point two
or more recent version perhaps but
that's the version I'll be using in this
video and I'm gonna look at this
functionality in the ml 5 library called
ml 5 neural network it is a function in
ml 5 that creates a empty or blank so to
speak neural network most everything
that I've showed you in this video
series so far has involved loading a
pre-trained model so a neural network
architecture that's already been trained
with some data and in this video I want
to look at making an empty a blank slate
configure your neural network collecting
data training the model and doing
inference
and the context that I want to look at
that is with real-time interactive data
so I'm going to come back and maybe use
some more traditional data sets there's
a data set that I that that's on the ml5
examples with the Titanic survival data
set I have the data set for my color
classifier series so I'll come back and
show you some examples of those as well
but in this first video I just want to
do something very generic which is
create a blank neural network use mouse
clicks to Train it and then then move
the mouse around for it to make guesses
or predictions and that might sound like
a weird thing to do and hopefully it'll
start to make sense as I build the code
and step through all the processes
alright so that was my beginning opening
discussion I did exactly what I thought
is sort of a problem which is that I
didn't show you anything like I didn't
like clicking browse around the website
and find the stuff but I do want to add
that in later we'll see how that works
all right I do see that there is a
suggestion about the audio context in
JavaScript it won't be happening today I
appreciate everyone's enthusiasm and
wanting to have their idea shown or
talked about but I'm on a particular
path and I'm just doing the topic that
I'm doing in the absolutely
computational geometry is on my list
anti-reflective coatings applied on
their glasses I thought I had that but I
will get it I'm gonna go get new glasses
it's another thing for my upgrading
light how bad is the reflection right
now cuz there is a way that I can turn
the light away for me and if you've
walked the teachable machine series the
third video has the light turned away
from me and it doesn't reflect but then
I also have this weird shadow on my face
I don't know all right so I'm gonna go
to this page ooh
so this shouldn't say come currently in
development cuz it's definitely here I'm
just gonna sort of scroll it down oh I
was gonna I want to talk about Rebecca
fie brink and wek inator so let me talk
about that
[Music]
and
[Music]
all right the reflection doesn't bother
at all okay so I also want to highlight
for you the weka Nader project which is
a free open-source piece of software
created by Rebecca free break in 2009
for training machine learning models and
I would especially encourage you to
watch
Rebecca free Brinks talk from the IO
conference in 2018 where she talks about
creativity and inclusion in machine
learning and goes through some
demonstrations of with Weka Nader and
processing and other pieces of software
so a lot of the work that I'm doing with
ml 5 is is entirely based on recreations
of many of the example demonstrations
that Rebecca fie brink made and has done
research about for years and years with
the Weka Nader project so in fact the
examples that I'm going to make in this
video and the next one and the next
follow-ups are direct ports in a way of
some of the original Weka Nader and
processing examples but I'm gonna do it
all in javascript in the browser with p5
and the ML 5gs library think what I'll
say also is
[Music]
and there's also a fairly lengthy
history of creative artists using
real-time training machine learning
models in real time please let me say
that again there's also a long there's
also a fairly lengthy history of
creative artists training machine
learning models in real time to control
musical instruments of performance a
visual art piece and I would encourage
you to check out some of these projects
Martlet by michelle and a guy from the
water spy and hedge this is not a
faraman by guillermo Montesinos in sofia
Suazo and the AI conductor by under a
stress card that I will link to in this
video's description for inspiration and
ideas okay so now though
let's see here
let me just quickly go to the getting
started copy this I just want to get the
library in the p5 Sketch
okay there we go um and how am I on time
11:20 all right c'est la vie
am I like I don't think this camera is
particularly level but it's fine right
you can oh let me check the focus at
least how's this whiteboard shot can you
see that how's the focus I can't tell if
I should if I should I'm afraid to touch
this camera it's very loosely mounted to
the wall I can make it a little sharper
I think that's better I think I just
improved it okay I shouldn't well
nevermind
yes I'm going to definitely refer to my
former explanations about neural
networks in general thank you Peter
okay our guide for figuring out how to
write the code is going to be the ML v
website and there's a page on the ML v
website for the neural network function
but before I start diving to the code
let's take a minute to talk about what a
neural network is now by no means am I
going to be comprehensive about this at
this moment in fact I'm going to give
you a very zoomed out high-level
overview and I would refer you to the
three blue one brown video series what
is a neural network which is one of the
most excellent videos on the Internet to
just quick to succinctly explain in
great depth what a neural network is and
I have gone through many different
playlists I guess I should be doing this
in front of the green screen case I want
to show any of this stuff oh yeah just
do it over here what you're gonna say
this again now by no means am I going to
give you a comprehensive explanation now
by no means in this video am i going to
do a comprehensive deep dive into what a
neural network is and how to code one
from scratch I will refer you to many
other wonderful resources where you
could do that deep dive starting with
the three blue one brown video what is a
neural network and some of the
subsequent ones I have also have a 10 to
15 part video series where I build a
neural network from scratch in
JavaScript based on a particular book
called make your own neural network that
is in Python I have other videos where
that our guides around machine learning
concepts where I talk about different
kinds of neural networks so I will link
to all of those in this video's
description but here I'm gonna use the
white board over here just to give you a
very zoomed out high-level overview of
what I'm talking about so a machine
learning system in the most basic sense
involves inputs and outputs
you know a classic example of a data
science approach to machine learning
might be we want to have some sort of
machine learning model that can predict
the price of a house based on some set
of factors so it might be the inputs in
this case might be the number of
bedrooms and the the LAT latitude and
longitude of where it is in the world
and the number of square the square
footage or square meters the size of
that house those inputs would be fed
into the machine learning model and the
output would be a number a price on this
by the way is called a regression which
sounds like a sort of terrifying term
and oh I have to be a PhD in statistics
to understand regression but what I mean
in this case a regression is the output
is some continuous number it's a price
it could be zero it could be a hundred
it could be it
1.5 million it's some number which is
different than the output being a
classification meaning it is a one of
several categories it's a cat or a dog
or a turtle or its Class A or Class B or
Class C so if you've watched my recent
teachable machine video series about
training an image classifier a sound
classifier all of those examples are
classification outputs the output that
you get is a set of confidence scores
and categories
interestingly enough I started with this
discussion saying I was going to give
you a high-level overview of what a
neural network is and I haven't even
begun that because I started talking
about a high-level overview of the
machine learning pipeline the process
and so in a way that's what this video
is also about and the way that I think
might be an effective is an an effective
way that I might be able to demonstrate
this to you is to kind is to find the
most drop dead simple almost trivial
scenario to show you all of those pieces
let me
yeah this is just the corner of the room
for people who are asking why boy I
something about the whiteboard today
very hard to race
I need a whiteboard cleaning system
this barker is pretty bad also it's just
this one's better yeah this one's better
so I will get to talk you about what a
neural network is but for the moment I'm
actually going to like stick with the
sort of full pipeline of a machine
learning project should really start
this whole thing over don't like my
explanation but whatever let's just keep
going all right I'm thinking I know
exactly what I want to do but I'm just
kind of confused about this roundabout
way that I'm doing this so let's say for
a moment that the goal that I have is to
train a machine learning model to use my
body as the input so maybe how I'm
moving my arms and legs and head that
will be the input and the output would
be a musical instrument a note that's
being played so I could somehow play
different notes based on how I move my
body this is this is a scenario that has
been this is a scenario that Rebecca
fibrin covers in great detail in her
course about machine learning and Weka
nader
i forget what it's called machine
learning for artists and musicians this
is this is an area that's covered in
great detail and Rebecca fie brings
course machine learning for artists and
creators what musicians know what that's
called
the worst artists and musicians yeah
okay I know you can't see it but I'm
recording it this is an area that's
covered in great detail in Rebecca
Phoebe brings course machine learning
for artists and musicians
a very simple one way that I might boil
this idea down into its very simplest
version is think about a 2d canvas and
it's very convenient that I'm using p5
because that's the thing that exists in
p5.js I have a 2d canvas and what I'm
going to do is I'm going to say there's
a mouse in that canvas and the mouse is
going to move around the canvas and
based on where it is it will play a
particular note now of course I could do
this with if statements very easily and
what what's the thing that the Kyle
McDonald quote Kyle McDonald I think I
actually put it in my syllabus somewhere
it's in this talk weird intelligence
interested in nice where some people
have something this is a really good
talk by the way great quote that I want
to reference I guess I guess I missed it
I'm not gonna find it I'm gonna give up
okay where is that from shoot anybody
know what I'm talking about
cuz I would like to reference it let me
give me one second to look for this Kyle
McDonald what is machine learning
and this is what I'm looking for in this
medium article I really like this
explanation
I don't think I'm going to find us I'm
just gonna have to say it my own words
instead of quoting Kyle maybe it was
actually might actually have been a
discussion here
hold on I know Kyle
oh it's this one it's this talk maybe
or not okay I give up sorry everybody
so many things around the world to look
at okay I give up I give up sorry I'm
wasting way too much time go back to the
if-statement thing now of course I could
program this same idea with an
if-statement but this is really what it
means to work with machine learning
instead of programming the rules
explicitly into code what I'm going to
do is give the code a whole bunch of
examples and have it learn those rules
so I want to demonstrate that process in
a scenario where it's very obvious how
it's working so that then we can build
on that into much more complex scenarios
where we're more sophisticated problems
could be or I guess really I'm just
saying we could build on that into much
more complex scenarios okay so the steps
are collect data to train model then
three I guess we can call this
prediction so we could that's also
sometimes referred to as inference
that's really when we're deploying the
model we're making use of the model
right here this is my representation of
the model I'm totally not talking about
what a neural network is
so in this case if I want to start with
a classification problem and I will show
you demonstrations of classification and
regression I'm going to have two inputs
input 1 and input 2 often refer to as
X's in a sort of machine learning
context those inputs are going to go in
to this machine learning model the
output is going to be one of let's say
three different categories so I'm going
to have three outputs notes like a B
well let's actually play a C major scale
the worst eraser ever
C D and E so two inputs and in this case
three outputs
a diagram is the weirdest-looking thing
ever ate the way it looks it is 11:30
says David okay I'm gonna get through
I'm gonna get through this explanation
then I'll take a short break before I
start with the coding
I feel like I'm not actually there's no
reason for me to explain I'm so I'm
really lost in like where I am in the
world of like what people who will be
coming to watch this will have seen
before what makes sense to explain and
not explain but I'm gonna just keep
pushing forward okay
my diagram looks a little bit weird so
I'm gonna fix it up for a second
this is like the craziest thing okay
so I have two inputs input zero input
one and three outputs C D or E
now all this time I've just been putting
the word the no now all this time I've
just been putting the letters ml in here
for machine learning or maybe referring
to this as a model because in truth
other things other kinds of algorithms
other types of ideas beyond a neural
network could slot in here but the ml 5
generic blank machine learning model
that you can train is a neural network 1
so if I were to try to zoom into this
for a moment what I would actually see
is something that looks something like
this
right that was to accept well this is
gonna be a really nice sped up moment
a neural network is an interconnected
set of nodes where that and at least a
feed-forward multi-layered perceptron
which is what this is is we're all is a
network where all of the data flows in
one direction the inputs come in here
they get processed by well the inputs
come the inputs come in here the inputs
come in here and get fed into what's
known as a hidden layer they get
processed by something called an
activation function and then they go out
of the hidden layer into the output
layer so this is really a two layer
network it has inputs and then two
layers a hidden layer and an output
later and a hidden layer and an output
layer and all of these connections have
weights to them and they're like little
dials that you can twist and turn to
process the information in different
ways
this is my zoomed in diagram of really
what's going on in here a neural network
is a network of neurons
multi-ball t-this is a technically this
is a feed-forward multi-layer perceptron
because the inputs which are represented
right here get fed through these
connections they're weighted connections
and get added up all together and arrive
in this layer which is known as the
hidden layer and there can be multiple
hidden layers and different kinds of
hidden layers but that data is summed
and processed through a mathematical
function called an activation function
and then fed out of the hidden layer and
into the output layer and the output
layer after all of the hidden outputs
are summed and passed through an
activation function we get a set of
numbers out and those numbers might look
like this
point two point seven point one meaning
there's a two percent likelihood that
this was category C a 70 percent
likelihood that this was category D and
a 110 percent likelihood that this was
category e so there's a lot more details
of what's going on in here and I
certainly once again would refer you to
the various things that I'll link in
this video's description but the idea is
that but the idea is that a neural
network is that process that is a neural
network is a kind of machine learning
model that can be trained all of these
weights can be adjusted so that but the
idea here is that a neural network the
idea here is that a neural network is a
machine learning model that can be
trained it can be shown a lot of
examples of inputs with their correct
corresponding outputs and it can tune
all of the weights of all these
connections so that when it later gets
new data it can make appropriate
predictions this is everything that the
ml5 library will take care of for you
and for us we're going to really just be
working with the inputs and the outputs
collecting our training
data training the model and predicting
outputs thank you thank you all right
finally she cut to the point messed up
the percentage what did I say 2% and I
say 2% a 20% chance of being a 20%
chance of being category C a 70% chance
of being category D or a 10% chance of
being category E okay alright um thank
you everybody for your patient
I said 7% oh my god it's only getting
worse
[Music]
okay
[Music]
just checking my phones 11:45 it's gotta
move quicker here all right so I'm
willing to take a minute or two to thank
whoops hold on
where are the sponsors of today's coding
train come on and so I am going to start
with - Lane so first of all if you go to
- Lang comm slash coding train that is
the link you'll want to use to check out
- Lane so here's the thing if you are
concerned at all about staying safe
online one of the things you really want
to have in your tool set is a password
manager I could not possibly live
without a password manager and in fact
if I come back here to my screen right
here and if I were to say you know if I
were to log out of the web editor and
just open it up and feel like I need to
log back in as you'll see here I can log
into my password manager - Lane which
will then pull up my password for the
web editor and get me logged in
instantly so it's the kind of thing
that's like a real pain on the internet
is to memorize and keep track of all
your passwords in a secure way and one
of the ways you really wanted to wanted
one of the things you really want to do
is have a different randomly generated
password for everything that you log
into and it's really hard to do that
without a password manager so the when
when you create a - Lane account you get
a single master password it's never
transmitted over the internet not even
two - Lane and not to their servers and
when you generate a long and complex
password for a new website in - Lane
it's bundled up encrypted using your
master password that only you know so um
you can see here just a whole lot of
quick demonstrations of like logging in
there's generating a password
one of the things I really also use that
I find really super useful is just like
having all of my like shipping
information and credit card information
driver's life Social Security numbers
stuff all saved in this very secure
method that I can just quickly have so
if you want to try it out
you can sign up for free for you get a
free 30-day trial of dashlane premium at
dashlane comm slash coding train and
then also if you purchase the the
premium account you'll get a discount
from the through through the coding
train as well so now in addition to a
password manager one of the things that
I need very very often is a web server
and so a new service that I've been
experimenting with and looking at is 'la
node so whether you're working on a
personal project are managing your
enterprise's infrastructure I don't know
if you'd I don't manage an enterprise's
infrastructure maybe you to Lou node has
the pricing support and scale you need
to take your project to the next level
they've got ten data centers world word
worldwide and they're launching an 11th
in Sydney Australia soon so here's the
thing you as a member as a viewer of the
coding train can get a lenôtre count
with $20 in credit today by going to
Linode comm slash coding train so you'll
get access to asset native SSD storage a
40 gigabyte network and an
industry-leading revamp cloud manager
which is built on an open-source single
page app Cloud Leno comm so you get root
access to your server you're gonna see
this right now this is the kind of thing
so like I my Twitter bot series you
could use Leno to like spin up your
Twitter bot you could do all sorts of
things
it has 1-click installs for WordPress
the lamp stack you can have a Minecraft
game server all that kind of stuff so
just to quickly show you if you go to a
Leno
coding train you'll get a nice welcome
message for where the $20 credit for a
news
drivers from the coding train and you
can give this service a try out and let
me know how it goes I'd be very curious
to hear the other thing I do want to
mention that the node let me know is
there also hiring so if you go to
lynda.com slash careers if you're if
you're a viewer of the coding train you
probably have some of the skills that
they're looking for in terms of their
hiring as well so feel free to check out
their careers apply for a job and tell
them that the coding train sent you so
I'm going to take just a couple minute
break to get a drink of water and my
iPad
oh no we created went down so I don't
have music to play and so I would
encourage you to go if you have a few
minutes to try signing up at - Lang comm
slash coding train and Linode comm slash
coding training both of those links are
in this video's description with also a
pin comment that has those links as well
and I'll be right back to finish writing
my code in about five minutes they don't
have any music to play but I'm gonna
mute my microphone so silence meditate
okay I'm back I
little break sorry for this silence in
the break i am i i'm gonna charge this
ipad up so that i can please have the
music our very sound effects for later i
can't put the charger it's so weird
like how did a second of going oh there
it is a longer cable really go a long
way right about now but what can I do
alright I'm still muted no no no okay
yeah no I'm not muted anymore okay thank
you
it's jus alright so I've got a little
time on a finish making this example I
want to make two examples so we'll see
how this goes
alright
I'm just looking at the documentation
yeah okay
ooh I like this okay okay
this needs a semicolon all right I'm
going to finally write some code in this
particular tutorial now that I'm hey now
that I've gotten through that
explanation I'm here to write some code
and all right oh let's take him in here
Dan man asks and thank you coma Borachio
and I I'm so sad that you're I I thought
I set something up that if somebody does
like a super chat message River will
like appear as an overlay but I really
do it right but Dan mass where can get
one of these so guess what I it's taking
me forever to do this and it's a very
disappointing to me how long it's taking
me to do this but it is happening I'm
about to relaunch the members program on
YouTube and make a bunch of changes and
I will be laser etching custom coding
training train whistles which I will be
sending out to new members so anybody
who's an existing member right now will
get one I'm gonna send one to everyone
whether you're joined a while ago look
not everyone sorry anyone at the $10
higher because it is kind of big it's
going there's gonna be a significant
expense with buying these not that
significant about buying them laser
etching them and shipping them so I
haven't figured out all the level stuff
but that is something that I will be
sending out I have some new stickers I
have like a member only exclusive it's
not a thing I'm gonna sell it's gonna be
an exclusive coding train laser-etched a
train whistle I'm gonna learn how to use
the laser printer by golly to do that
all right
I like how Bruno writes in the edited
version I may be 50 seconds into the
video I'm like an hour and a half into
here okay that was Japanese yen yes all
right so that's coming I mean I think
that I'm gonna have that I would say in
early 2020 Jan you mean that's my guess
so anyway lots more launching a new
store I've mentioned this before about
huge thank you to standard TV which is a
company that works with a lot of
wonderful other YouTube channels and you
can find all of the creator stores here
and I'm hopefully going to be here soon
they helped me with the sponsorships and
they also have a service called nebula
that you should definitely check out and
there was something else about standard
they don't want to say oh the these
thumbnails which I am absolutely in love
with were created by Simon who's a
designer who works with standard TV so
anyway right goodies for the patreon
subs yet um so David's kick I don't want
to I gotta get back to coding and stuff
and I don't want to but my my plan I I
know that you want to stay through
patreon which is absolutely fine
I'm not going to delete the patreon but
all any goodies that our YouTube members
the goodies will be the same for YouTube
members or patreon subscribers but I
there are a few things that YouTube will
allow me to do in terms of member only
stuff that if you're on patreon you
won't be able to get access to but in
terms of mailing something or any other
rewards like invitation to slack or
discord or whatever use that's and I did
get github sponsorships unlocked so I
might have I might make github
sponsorships the preferred alternative
to YouTube memberships if you don't want
to if you don't want to but I'll be
giving part of your funding money to
Google which frankly you are if you sign
up through YouTube membership they take
quite a large percentage you know in my
mind it's a reasonable percentage it's
I'm getting getting a good service here
but okay to the code how I got a login
shoot here's my dashlane ad I'm logging
in through dashlane which is logging me
into the web editor and yeah I want to I
want to leave this page okay
I'm starting with a p5 okay now that
I've gotten through that explanation I'm
I really want to just write some code
and show you how this all works so I'm
starting with a p5 sketch that also is
referencing the ml 5 library zero point
four point two as of today but that's
not the important part
I want to go back to my JavaScript file
and I have that here so what is the code
that I want to write so I want to make a
variable called model so I'm gonna call
it you could call it neural network or
machine learning classifier thingy I'm
gonna call it model and my model is
going to be a new ml 5 neural network so
this is neural network as a function you
can call in the ml 5 library that
creates an empty version of what is
right here and it's up to us to
configure the inputs and the outputs so
one thing and the way that you can do
there's a variety of ways you can do
that but I'm going to show you how to do
that by creating a variable called
options which is just a JavaScript
object that has the configuration for
the neural network and then the options
gets passed in when you create the
neural network so the things that I want
to do is I want to give it a certain
number of inputs in this case to a
certain number of outputs in this case 3
and then also I want to tell it what
kind of task I want it to do
a classification super chat from Martin
W Thank You ma team trees says epic
picks team trees super chat from I
understand thank you I want those
overlays off to figure that out for the
next time incidentally if how do I know
this is what I type in here if I go to
whoops not processing if I go to the
neural network documentation page on the
ml 5 website all of this is
documented here and probably what's most
useful is right here to show you this is
exactly what I've done the number of
inputs the number of outputs and then oh
it says type I thought this is task
I think it's task just say type that's
weird let me look at the examples I kind
of think it should be task could be type
[Music]
tasks I think I'm pretty sure it's tasks
I think that's a I think that's an error
in the documentation as my memory is
that it's tasks
so I'm gonna leave it as that summers
incidentally and I'll cover this in a
future video if your data is something
that's in a file you've already
collected it maybe it's in a JSON file
or a comma separated values file a CSV
file you can actually load that file as
part of what the neural network and it
will use that file to train the neural
network but I'll come back to that in a
future example where I'll show you a
scenario where that makes sense in this
case there is no data yet I'm going to
collect the data in my p5.js sketch
itself in addition to another way that
another way that I can also create the
neural network is instead of just
specifying there are two inputs and
three outputs I can also give names to
the inputs this isn't something that a
neural network needs or even uses but
it's a way that's very useful as a
programmer creating the neural network
for me to keep track of what's going on
to name my inputs and name my outputs so
that's actually the way that I want to
do it in this particular example so I'm
going to change the number of inputs to
an array of names and the outputs what I
say I'm going to do the note C D and E
so this now is what it looks like
with the inputs named I instead of
saying - I'm gonna give an array with
two strings in it instead of saying
three I'm gonna give it an array with
three strings in it so many super chats
going on I will try to come back and
thank them or I need a way of keeping
track of them good job keep it up says
Igor Thank You Igor and there was also
one from I understand Thank You Nathan
for being me Manuel super chat alright
where are we now in terms of these steps
we're in the collect data step I want to
collect data
to do that I'm going to make an array
I'll call it a training data and every
time I press the mouse I will collect a
data point so I'm gonna create I'm gonna
create a variable called a sample a
sample meaning like one data record one
instance one sort of slice of the data
and it's going to have an x value which
is going to be Mouse X a Y value oh wait
a second this is not how it works is it
how does this work if
I guess I sail a ball I'm doing
classification and you just call it
label
like when you're doing classification
with oh no let me look at the
documentation
oh no that's how it works there unless I
don't actually give it the number that's
weird it's funny we went around in
circles with this and I think I'm
forgetting how it works
because I did the examples that I made
didn't use classification does it keep
it figures out the number of labels
doesn't make any sense
hold on let me let me go to my examples
from my class because I have this
example and here yeah this is what this
is the example that I'm intending to
build
I can't use the computer why is this not
chained there we go
so what I want to do is change this to
okay pretty sure we added this support
here sorry everybody
figuring this out stuff is hard now
getting started copy to clipboard okay
sketch
let's see what happens
X is what I'm doing is
this doesn't make any sense how this
would work with classification
can I just do this maybe if I just do
this right oh I'm gonna try it like this
and see oh no let me see if this works
so I give it a bunch of A's change it to
be give it a bunch of bees train hey bee
oh so this is working so that's how it
works you just give it the all right
great
so it works the way it's gonna work the
way I want it to work fine I just had to
understand what I was doing
okay
sample with an X that is Mouse x and a y
that's Mouse Y then I also need a target
a target is because I'm collecting
training data I need to not just only
collect the inputs and actually maybe
actually mmm you know what I'm gonna I'm
gonna change it like this actually let
me call this inputs because this is
really what I'm doing I'm collecting
what the inputs should be for this
training data so the inputs are X is
Mouse X Y is Mouse Y and then the output
I also need to have the output which is
some particular note that should be
associated with this x and y but I'm
gonna actually call that a target
because it's this is training data so in
the end oh boy why did this go off oh
dear this camera is so off
in the end I want in the end I want the
neural network to guess the note for me
but I have to give it some examples of
what I want so in this case let's just
say it's going to be C and then I can
add this data to the model so I'm gonna
say model add data the inputs associated
with this particular target then just so
I can see what's going on I think I
should save all of this training data
I guess I don't need to save it I should
just draw it here do you wanna
that's the way that's going to make
sense
yeah
oh I could do can I do that like object
Street destructuring thing I want to
save all the data so I'm going to use
that array that I created earlier and
say training data dot push and I'll make
a new object that has the inputs and the
target in it
and then in the draw loop I can loop
through everything
and visualize the data onto the canvas
drawing a circle and then also drawing
the category for that and then also
drawing the class associated with that
circle inside the circle
let's run this and see if it works great
so as I click around we're seeing all
these data points that all have an XY
associated with them and a label
associated with them in this case
hard-coded as C input provided is not
supporter does not match your output
label specifications now I am getting an
error here which says that input
provided is not supported or does not
match your output label specifications
so I think I've made a mistake here let
me see if I can figure out what that is
do we say 1215
[Music]
in both outlets yeah
where did I just like pulled up an
example yeah this worked what's
different
is it really type and not tasks that we
did a change to type no this is using oh
yeah hold on
duplicate let me see let me save this
reference neural network no no no
getting started copy this worked right
and data
oh I know what the problem is I know
what the problem is and I know what the
problem is the target has to be in an
array because there can be multiple in
many cases there's multiple outputs
all right aha I have found the error of
my ways very common mistake in this case
my target is the string see the category
see I want to play ultimately I want to
hear the note see played but in many
cases there could be multiple especially
in a regression problem sorry in many
cases and you'll see this in future
examples that I'll demonstrate there
could be multiple outputs whether it's
multiple categories or multiple numbers
there's lots of possibilities here
and so just the the outputs themselves
[Music]
yeah it really should be there should be
a different way of doing this need to be
but this is the way it is right now the
outputs themselves need to be in an
array so I needed to put this bracket
here a round target because I'm taking
the category C and that individual class
in an array with one thing in it is the
actual target that I want to give to
this particular model so let me run this
again and see if that error goes away I
don't see that error anymore now I need
some method by which I select what the
training label is and so I'm going to
create a variable called target label
set that equal to C I'm going to have a
function called key pressed and I'm
going to say training label equals the
key that was pressed a console.log a
training label so I'm going to just do a
quick and dirty interface which is
really no interface to have the label
set by when I press the key and I'm not
doing any error checking to make sure
I'm just doing C D or e only but all
that could come you could add that and
and then the target should be that
training label itself and let me run
this now whoops
training label sorry target label not
training label CCC letting press D no
that didn't work
Oh
training label it's called target label
and let me just make sure it's uppercase
to be consistent si si si si si si si si
ddddd e so I now have collected my data
what is the next step the next step is
train the model and luckily for us this
is a very easy step for us to accomplish
simply by calling a function in the m l5
neural network library called train and
yes it is a train I'm going to add an
extra function here that the next I'm
going to check if the key happens to be
pressed as T now I am going to call
model train now when I train the model I
also have some options that I can that I
can specify and there are a variety of
things and I could sort of come back and
talk about some of these terms and how
they affect the process maybe in one of
my subsequent videos but for right now
I'm going to just talk about one
particular term and that term is epochs
so I'm gonna say epochs 10 I'm gonna
train it based on these options and I'll
come back and say so what is he box so
what is he pox look at this summit oh
something's control how did that get in
there oh because I'm like typing keys
all the time and then I click the mouse
I should validate it but whatever shoot
I just want to
CDE
[Music]
all of these data points are going to be
fed into the model as part of the
training process one at a time the
inputs along with the target the inputs
get fed in the model makes a guess if
it's gotten it correct moves on to the
next one it feeds the inputs in the
model makes a guess if it's gotten it
incorrect adjusts all of these dials all
over the place these weights of the
neural network towards the error to try
to correct that error and then starts
over again it's feeding in all the data
one at a time so what is an epoch an
epoch is one cycle through every single
data point fed into the model so maybe
there's 35 here if I have 10 epochs I'm
feeding in all 35 data points and of
course the camera is overheating it's
really not that hot in here and this fan
on move the air around a little bit nuts
not the coding train if the cameras
don't just shut off every once in a
while
so if there are 35 of XY target trios so
to speak then and I do 10 a pox
then it's doing all 35 of those 10 times
or 350 training cycles through the
neural network itself now interestingly
enough and this is built into ml 5 it
shuffles the order all of these randomly
because I collected all the C's than all
the DS and then all of the ease and the
model wouldn't trained very well if it
didn't do that but that's something
that's built into ml 5 itself so I've
set the epochs
I've set I've set the epochs and now the
train function and tell ya it's gonna
take some time and actually has multiple
callbacks associated with it then go to
the page
where does they send an error I guess
who knows okay
okay
there's a while training callback and
this is a function and event that's
triggered this isn't a function and
event that's triggered every at the end
of every epoch and then there's a
finished training callback and this is
triggered just once when the training
process is complete let me write those
functions while training finished
training in finish training I'm just
gonna add a console log
and the wild training callback will be
sent two arguments one argument is what
epoch are we on and the other argument
is a value called loss now ultimately I
only need the while training callback if
I want to sort of debug what's happening
during the training process so for
actually for a moment I'm just gonna
console.log the epoch and I'm also going
to add another property up here in the
original options which I'm going to set
as debug true because often when you're
training a machine learning model you
want to see a visualization of the
training process and how it's going and
there is a particular library called TF
viz so ml 5 is built on top of
tensorflow Jas and there is a
visualization library associated with
tensorflow Jas that will draw graphs and
different things about the training
process so setting debug to true will
make that happen automatically and I'll
show you exactly what I mean in a moment
it's possible that I forgotten something
but I think I have all the pieces here I
have my options which I want to train
over 10 a pox I have a wild training
callback where I could just see every
Bock well epoch one at a time in the
console and it'll tell me when I'm done
and I've turned debug on so I should see
a visualization so let me move my screen
around so that I can see all this stuff
collect my data
and now for the moment of truth I'm
gonna press the T key and as soon as I
press that the training process should
start I should see the epochs being
logged here and a visualization over
there let's see what happens oh oh I
forgot some steps I forgot some steps
I thought this would work anyway
I thought we fixed it so that it would
work just like finished immediately so
there is there's an important function
which I was going to demonstrate
okay yeah it's supposed to work without
this I don't know why it didn't that's
annoying I thought it works without this
let me see here is there if I don't want
to normalize the data is there like yeah
that's weird
so it's supposed to work
12:30 oi
yeah weird so we had fixed it I thought
so that you don't I was going to talk
about how normalizing is an important
thing but I guess I'll just
[Music]
hmm that's weird because I I remember
going through the source and we added
something that if you don't normalize it
it will finish preparing the data but
all right
unfortunately I missed an important step
and I meant to talk about this
afterwards but I think I need to talk
about it now so one of the things that's
very typical of working with a machine
learning model in particular neural
network in particular a neural network
based machine learning model one of the
things that's very important about
working with a machine learning model in
particular a neural network based
machine learning model is the fact that
data should be normalized before it's
fed in as inputs into the system and
what do I mean by normalized what I mean
by normalize is take any arbitrary data
look and squish it or squash it or
standardize it for all the values to fit
between some well-defined range so in
this case if I have this canvas and
everything in the canvas is an XY point
oh you can't see that in this case if I
have a canvas and everything is an x and
y point in the canvas I'm getting values
like 100 pixels by 100 pixels but I want
to normalize those pixel values into a
number between 0 and 1 so if the width
is 400 of the canvas all I need to do is
divide by 400 but ml5 has a utility in
it that will normalize the data for you
we'll just look at it examine it find
the minimum the maximum and squish
everything down to a value between 0 and
1 and to do that all I need to do is add
one more line of code right when I'm
finished collecting the data are right
before I'm out to train the model and
say model dot normalized data let's give
this a try again I'm gonna collect data
now I'm really going to train the model
and it's totally not working what have I
done wrong here all right
this is a fail
this would have been much easier if I
hadn't bothered this would have been a
better way to demonstrate it I guess
this should work no wait
target label is this
what's going on
inputs to outputs three classification
debug oh the way I'm drawing it is
different
[Music]
why is everything always so hard well
that's promising
is it just like okay that's good I am 10
epochs is not enough
should get like a really really low loss
let's try this example basically the
same example
I really need to I mean I wanted to
demonstrate how I could save and just
reload the data so I don't have to do
this each time because it's kind of
ridiculous what I'm doing here why is
this like not
yeah this is what I expected to see
so this is working a hundred epochs
why did I mess up
X Mouse X mouse Y XY
semicolon line 18 I don't think that's
the problem all right let's see here
try to make this very distinct how many
epochs did I put in there 100
a lot more data you really should be
able to do this with very little data
especially with a lot of epochs
here we go okay there we go
so amazingly it just need it's just so
little data I guess it needs a lot of
epochs and I should have gave me an even
more cuz it's just so little data
[Music]
although I guess I could probably mess
with the learning rate I think it's
called learning rate I'm just curious
maybe I'm point to five these are the
defaults but as soon as I do
classification No
just curious hold on let me save the I'm
gonna actually save the data well you
know what I'm actually just gonna I'm
gonna leave it
let me try this again with many many
more epochs I'm realizing it's just very
very little data so in order to make it
seem like it's a lot more data I can
just increase the number of epochs and
I'm gonna collect some data yet again
I'm gonna show you how you can save the
data to reload it so you don't have to
keep collecting it over and over again
if you're trying to debug your model
very important thing but I'm just gonna
collect it again
press train
and very good so what I'm seeing is
exactly one of what I want to see I want
to see this graph of a line that's going
down and down and down and down and down
as low as it can go done and and we can
see here in the console these are all
the epochs it got up to epoch 199 and
then said done so what is it graphing
over there
Oh scammer has gone off
it's graphing a very particular it's
graphing a very important property
that's part of its graphing something
called loss now we could actually look
you might recall at we could actually
look we could actually look right here
in the wild training function at the
actual loss value itself what the loss
is I like lost my I think once I get to
hours day and I like lose my ability to
do this let me start this whole lost
explanation in thank you Simon that's
gonna be useful in a moment if I could
ever get to it it's the graph is of the
loss loss is a particular value a
measure a metric of the training process
it's a summation of how many mistakes
it's making as those trained as the
training data is fed through the neural
network so we're again remember the
training process is take a particular
data point feed it through the network
it's going to make a guess
compare the guess to the correct answer
if it's the correct answer guess what
the loss is zero the error is zero if
it's not it's going to be far or close
to that error and by accumulating all of
the errors over one Epoque that value is
summarized in loss so as we can see as
it's training over time the loss starts
up at like a value of one point one and
it gets in actually we can see here in
the graph at the very end we were down
to a loss of zero point zero seven
thirty four to six which is a pretty
good loss anytime you see a value lower
than 0.1 in these kinds of scenarios
it's doing particularly well and you
could see the graph is starting to level
off maybe I could have eat out a little
bit lower loss by giving it more epochs
but most likely that was good enough
okay
whoops
finally in this rather lengthy tutorial
video we are ready for the last stage
prediction I have trained the model and
now it's time for me to give it new data
new XY coordinates and have it guess a
music a note CDR e based on that
coordinate and you may have noticed that
as I was trading the model the data that
I was giving it happened to be very
distinct I wanted to learn that when my
mouse is over in this corner play the
notes see when my mouse is in that
corner played D and towards the bottom
play E but if I were to experiment with
this a lot it would be very interesting
to train the model with a variety of a
variety of distributions of how I
collect this training dataset
one thing I want to do here an important
feature to this example that I think I
want to add now is having a sort of
state so what is the state and I'm going
to say the state at the beginning is
collection and so in this case that's
going to affect what happens you're
distracting me with your sharing of
YouTube videos in the slack channel I'm
gonna use that state to determine what
should happen in the mousepressed
function so if the state is collection
if the state is collection and training
data otherwise if the state is
prediction make a guess so I need to add
the code for making a guess in a moment
but let's figure out how I'm going to
sort of track this state over the course
of the program and I look forward to all
of you who changed this to do a switch
statement and show that with me at the
competence so as soon as I press the key
T the state should be training and then
once I'm finished training the state
should be prediction
at the prediction stage I want to do the
same thing I want to take the inputs and
send them into the neural network but
this time I'm not giving in a target
there is no target I just want the
neural networks prediction or guess and
in this case because it's a
classification problem I want its
classification I want you and in this
case because it's a classification
problem so prediction is the label I'm
gonna say model dot and in this case
because it's a classification problem my
prediction is actually classify I'm
asking the model to classify so I'm
going to say classify these inputs send
those inputs into the model and when
you're finished give me a result back in
a callback so write the got results
function the got result function can
take multiple arguments error or results
if there's an error do nothing
otherwise right now let me just take a
look at the results
this is really nuts that I've got to
collect the data every time I do it I'm
definitely gonna have to find a way
around that which I have one I will
demonstrate that soon but I'm just going
to collect it again
training the model mm-hmm mom loss you
can do it
now we are ready
oh it Hardy I already it's just
registering all my mouse clicks so I
should probably constrain it to only
registering the mouse clicks on the
canvas but I'm gonna click up here I'm
in the trim in the prediction stage I'm
gonna click in the top left and if I
click on the top left around the cluster
of the notes see I should see that the
highest confidence score classification
that gives me back is the category C
click and it's this one here the second
one object 0 look at this nice I'm so
glad this worked 98% confidence that
that click registers a label of C let me
click over here 86 percent confidence
the label e so the results that come
back in the results variable in the gut
result function R this is the same as
every other nullify function that I've
demonstrated to you an ordered list of
the labels sorted by confidence score so
there's only there's always three
possibilities each with a confidence
score and it's always going to put in
the array the highest confidence first
just I'm just Chad because I'm over time
I'm checking my phone here okay no
emergency messages this example is
ultimately finished I mean there's been
no thoughtfulness to the interface here
or why it is you might want to make
something like this this is really a bit
of my hello world introduction to that
neural network function in ml v itself
however to make this feel at least like
something that has some application to
it I want to add the feature that
whenever I'm creating the training data
it plays the musical note as I click and
then when it's in the prediction stage
it once again plays its guess as a
musical note when I click so I'm not
going to I'm gonna sort I'm not going to
show you all the details of how the this
is coded here I'm going to go grab code
from one of my examples that uses the p5
sound library and an oscillator and the
envelope class to play a musical note
and then I'm gonna put that in this code
and demonstrate it to you so if I go to
let's see question is what's the chance
that I could find this code the sound p5
jazz sound envelope sound envelope this
is what I want
this is the code on github for my sound
envelope tutorial so I'll link to that
particular video if you want to watch it
but I'm just gonna start grabbing this
code and putting it in my ml 5 neural
network example
so where where's the mouse
Oh ha ha I'm adding it to the wrong
example I added it to the other example
let me close this wrong example goofball
it's like why does this look so
different
let me actually capture this sound
[Music]
now you're getting the sound I think I
want this this doesn't really sound what
is it attack decay sustain just you I
don't know I wanted to sound more like a
piano notes somebody could give me some
set range 1.2 to zero what does that do
whatever someone could give me some
better numbers to put in here but now I
want C D or E so I need to get those
frequencies
yeah that's a good idea Simon I will do
that also
I'm waiting for like some good ASD our
Valley is to do the next part on my
other side okay I know I don't really
need it to sound like a piano
I just just sounds kind of like I want
it to be a quick note this is what I
want
yes well that's the decay I guess I
should just go back to whatever I had it
for my example
perfect alright this is not important to
this tutorial so I'm just going to move
on now that I've added an envelope and
an oscillator I just call the play
function every time I click the mouse
and you can hear a note being played
but I want to play a see a D or an e so
I need to get the exact frequencies for
those particular notes that I want to
play I can grab them from this Wikipedia
page for piano notes and I'll get middle
C d4 and e4 I'm going to make an object
that just has those values
and so this is my lookup table based on
whatever category it is I want to set
the wave to that particular frequency
so right before I play the envelope wave
frequency frequencies based on the
target let's see if this works
[Music]
and now it's playing CD or e based on
when I click
now I can pull the note which is the
label associated with the first result
since then sorted it's a sorted list and
I can and I can set the frequency based
on that note and play the envelope again
and probably it would be good for me to
also draw it but I'm gonna I'll leave
that to you to make a much nicer
interface for this and I'm just gonna
finish this off by collecting the data
one more time and then having it play
the notes as I click around and this
time maybe I'll give it a bit more of an
odd this time maybe I will give it a bit
more of a less obvious or for uniformly
distinct spatial arrangement of the
training data
here we go training data time
[Music]
there's my data train the model I don't
know if that control that got in there
it's gonna break it we'll find out train
the model
we're started reading the chat now I
just saw his read that don't over fit
yeah and now let's see what happens
wait huh
Oh what did I forget
do I have an error because of that weird
Oh freak was not defined oh no oh no oh
this was it all that work and I forgot
the S there let me fix that and do it
again Oh Oh p5 OOP OOP I didn't realize
this but it's actually called I should
call it p5 envelope not env
[Music]
train the model
I finished training and now in theory it
should do prediction
we zoom in so you can see this a little
better
look it's even giving me a c-note here
that's its best prediction based on all
the C's up there
be really interesting to visualize the
the every sort of like what the value
would be for every pixel that's
something you should do as an exercise
[Music]
so imagine even though this is kind of
an obvious and almost trivial scenario
imagine if you were using your hands to
and maybe you had a sari now this is an
obvious and somewhat trivial scenario
but imagine expanding on this imagine
having many more notes imagine having
the input to not just be a single mouse
click but perhaps an XY of your tracking
your hand maybe with the pose net
feature of ML 5 maybe you're tracking
two hands so actually training the model
to learn based on four inputs your
entire pose I'm gonna get to that so and
then you have a lot more notes than just
three you could imagine how you could
expand this to start playing a musical
instrument based on how you move your
body and this is the sort of seeds of
that idea in this very basic example
there are a lot of missing pieces to
this example and so the two things that
I well it's really three things the
things that I want to demonstrate and
I'll do a follow-up video where I will
add these features in is one I would
really like to be able to a save the
model I train so I could just load it
back in and another sketch I want to go
through training it again that's quite
possible to do I also might want to just
save the dataset like maybe I don't want
to save the model but I want to save the
data set because I want to try training
it again but with slightly different
parameters I don't really showed you
what are the kinds of hyper parameters
you can change for training the model
but there are some so I want to show you
saving the data saving the model and
also what if I wanted to make this
regression instead so right now it is
always playing a very specific note only
one of three possible notes but what if
what I wanted to do when I clicked over
here I wanted to hear an interpolation
of what it sort of guess would be in
this case kind of like somewhere between
C and D probably I'm about halfway in
between those clusters so how could what
note would it play if it was returning
an actual floating-point frequency value
and this actually would be very easy for
me to adjust this example mostly all I
need to do is change this term from
classification regression and then
change the way I read the output
it but I'm gonna still do that in a
separate video follow-up that will come
after this maybe try that on your own
and then see what happens in the video
that I it might not be released right
now if you're the times you're watching
this but hopefully it is alright thanks
for watching and I'll see you in the
next ml 5gs beginner's guide to machine
learning video oh okay boy that took me
all this time just a date-like make this
one video tutorial
I don't know I'm kidding this is this I
don't know what that what what this sort
of general audiences of you all of you
according to my stream deck here 382 if
you're watching if this was illuminating
or interesting at all I would be
certainly be curious for feedback I
wonder
so I think I probably got ahead out I'm
about 45 minutes later I do kind of want
to like I would love to just like
rapid-fire fill in those next few steps
but I don't know that I really have time
for that is there are there any
questions I could answer that anybody
has okay good I'll be your giving you're
giving me nice feedback which I
appreciate epic picks is oh yeah so if
you want this is the nice thing is you
can get this example right now so if you
want to run this particular example it's
at this URL maybe somebody could maybe
somebody could pay post that into the
chat sorry somebody who has chat
privileges could do that oh can I do
that no not easily
do I have red in my beard no but I have
gray could you do this with the makey
makey yes that would be a wonderful
thing to think about what other kinds of
inputs could you have that are like
sensor inputs so I think I don't know
when I'll be back next oh I couldn't
easily wear next Friday I have a guest
coming and the guest I should just say
who it is Shirley woo who is a data
visualization artist she's gonna do a d3
tutorial so maybe I can find some time
before next Friday to come back and
finish doing finish doing the this
example so a fluke asked a great
question what is this building towards
like what does this have to do going
Thank You solar line or Nathan for
posting the link to the code so I'm
building towards maybe something that
would be a musical instrument that you
play with your body so ultimately the
example that I want to make is I'm
taking I'm the training data is I'm
collecting different poses like when I
stand like this it's the musical notes
see when I stand like this it's a
musical note D when I stand like this
it's the musical note e and so then I
want to I want to play a song by doing
this that's what I'm building towards
actually alright umm oh I don't have I
can plug back I this iPad is charging a
little bit
and I'm not now
come on iPad this is very important that
I have music to play as I go leave why
is this I think I used to be able to do
this stuff much faster so harsh I'll ask
I'm doing a master's thesis on ml and I
need some help may I mail you so I get a
lot of email and I very much appreciate
all the emails I get and I I actually I
do read them all I it's very hard for me
to answer coding questions I try to
prioritize I mean the sort of students
who are students at NYU who are taking
classes and then we also have if you're
a member a slack channel where people
can get help with questions you welcome
to email me if but I don't I don't have
a good system I would recommend more
posting on a forum maybe we could create
maybe the coding train discord that sort
of stuff so close to 1 million I know at
this pace I think I'll hit mean who
knows maybe it will go down from here
but I think I would hit 1 million
subscribers in about 4 or 5 months so I
should plan something special for that
ok so I was trying to get this to play
my I don't know why it won't but that's
like home everything's messed up right
now with my tablet here I can't get it I
just wanted to play my oh I should read
you some random members
I'll read some random numbers 2.06 770
4831
Oh quick today's today's coding train
which surely was brought to you by -
Lane
- link calm slash coding train and
Linode Lenovo lynda.com slash coding
train you can get a free month from -
lame and you can get a free $20 in
credit from you know I'm as well as a
discount with - Lane but also today's
coding train is brought to you by the
random numbers seventy four thousand
eight hundred thirty one and fifty six
thousand one hundred and ten also the
random numbers eighty 1963 seven
thousand five hundred eighty three and
sixteen thousand four hundred and
seventy three also the numbers nine
thousand six hundred twenty four and
eighteen thousand nine hundred and okay
goodbye everybody I will try to answer
any questions if I can but I'm moving to
the wallpaper stage and I will see you
all soon next week next Friday for sure
if but maybe sooner maybe sooner if I
can find some
[Music]
I always forget
[Music]
never forget this stop I'm gonna do this
stuff this stock this dot this star this
start song never forget the Vista
there's somebody composed that song for
me