Placeholder Image

Subtitles section Play video

  • [MUSIC PLAYING]

  • LAURENCE MORONEY: So the first question

  • that comes out, of course, is that whenever

  • you see machine learning or you hear about machine learning,

  • it seems to be like this magic wand.

  • Your boss says, put machine learning into your application.

  • Or if you hear about startups, they

  • put machine learning into their pitch somewhere.

  • And then suddenly, they become a viable company.

  • But what is machine learning?

  • What is it really all about?

  • And particularly for coders, what's machine

  • learning all about?

  • Actually, quick show of hands if any of you are coders.

  • Yeah, it's I/O. I guess pretty much all of us,

  • right, are coders.

  • I do talks like this all the time.

  • And sometimes, I'll ask how many people are coders,

  • and three or four hands show up.

  • So it's fun that we can geek out and show a lot of code today.

  • So I wanted to talk about what machine learning is

  • from a coding perspective by picking a scenario.

  • Can you imagine if you were writing a game

  • to play rock, paper, and scissors?

  • And you wanted to write something

  • so that you could move your hand as a rock, a paper,

  • or a scissors.

  • The computer would recognize that and be

  • able to play that with you.

  • Think about what that would be like to actually write code

  • for.

  • You'd have to pull in images from the camera,

  • and you'd have to start looking at the content of those images.

  • And how would you tell the difference

  • between a rock and a scissors?

  • Or how would you tell the difference

  • between a scissors and a paper?

  • That would end up being a lot of code

  • that you would have to write, and a lot

  • of really complicated code.

  • And not only the difference in shapes--

  • think about the difference in skin tones,

  • and male hands and female hands, large hands and small hands,

  • people with gnarly knuckles like me,

  • and people with nice smooth hands like Karmel.

  • So how is it that you would end up

  • being able to write all the code to do this?

  • It'd be really, really complicated and, ultimately,

  • not very feasible to write.

  • And this is where we start bringing

  • machine learning into it.

  • This is a very simple scenario, but you

  • can think about there are many scenarios where it's

  • really difficult to write code to do something,

  • and machine learning may help in that.

  • And I always like to think of machine learning in this way.

  • Think about traditional programming.

  • And in traditional programming, something that has been

  • our bread and butter for many years--

  • all of us here are coders--

  • what it is is that we think about expressing something

  • and expressing rules in a programming language,

  • like Java, or Kotlin, or Swift, or C++.

  • And those rules generally act on data.

  • And then out of that, we get answers.

  • Like in rock, paper, scissors, the data would be an image.

  • And my rules would be all my if-thens

  • looking at the pixels in that image to try and determine

  • if something is a rock, a paper, or a scissors.

  • Machine learning then turns this around.

  • It flips the axes on this.

  • And we say, hey, instead of doing it this way

  • where it's like we have to think about all of these rules,

  • and we have to write and express all of these rules in code,

  • what if we could provide a lot of answers,

  • and we could label those answers and then have a machine infer

  • the rules that maps one to the other?

  • So for example, in something like the rock, paper,

  • and scissors, we could say, these

  • are the pixels for a rock.

  • And this is what a rock looks like.

  • And we could get hundreds or thousands of images

  • of people doing a rock--

  • so we get diverse hands, diverse skin tones,

  • those kind of things.

  • And we say, hey, this is what a rock looks like.

  • This is what a paper looks like.

  • And this is what a scissors looks like.

  • And if a computer can then figure out

  • the patterns between these and can be taught

  • and it can learn what the patterns is between these,

  • now, we have machine learning.

  • Now, we have an application, and we

  • have a computer that has determined these things for us.

  • So if we take a look at this diagram again,

  • and if we look at this again and we replace

  • what we've been talking about by us creating rules, and we say,

  • OK, this is machine learning, we're to feed in answers,

  • we're going to feed in data, and the machine

  • is going to infer the rules--

  • what's that going to look like at runtime?

  • How can I then run an application

  • that looks like this?

  • So this is what we're going to call the training phase.

  • We've trained what's going to be called a model on this.

  • And that model is basically a neural network.

  • And I'm going to be talking a lot about neural networks

  • in the next few minutes.

  • But what that neural network is-- we're going to wrap that.

  • We're going to call that a model.

  • And then at runtime, we're going to pass in data,

  • and it's going to give us out something called predictions.

  • So for example, if I've trained it on lots of rocks,

  • lots of papers, and lots of scissors,

  • and then I'm going to hold my fist up to a webcam,

  • it's going to get the data of my fist.

  • And it's going to give back what we

  • like to call a prediction that'll

  • be something like, hey, there's an 80% chance that's a rock.

  • There's a 10% chance it's a paper and 10% chance

  • it's a scissor.

  • Something like that.

  • So a lot of the terminology of machine learning

  • is a little bit different from traditional programming.

  • We're calling it training, rather than

  • coding and compiling.

  • We're calling it inference, and we're getting

  • predictions out of inference.

  • So when you hear us using terms like that,

  • that's where it all comes from.

  • It's pretty similar to stuff that you've been doing already

  • with traditional coding.

  • It's just slightly different terminology.

  • So I'm going to kick off a demo now

  • where I'm going to train a model for rock, paper, and scissors.

  • The demo takes a few minutes to train,

  • so I'm just going to kick it off before I get back to things.

  • So I'm going to start it here.

  • And it's starting.

  • And as it starts to run, I just want to show something

  • as it goes through.

  • So if you can imagine a computer,

  • I'm going to give it a whole bunch of data of rock, paper,

  • and scissors, and I'm going to ask

  • it to see if it can figure out the rules for rock, paper,

  • and scissors.

  • So any one individual item of data

  • I give to it, there's a one in three

  • chance it gets it right first time.

  • If it was purely random, and I said, what is this,

  • there's a one in three chance it would get it correct as a rock.

  • So as I start training, that's one

  • of the things I want you to see here

  • is the accuracy that, the first time through this,

  • the accuracy was actually--

  • it was exactly 0.333.

  • Sometimes, when I run this demo, it's a little bit more.

  • But the idea is once it started training,

  • it's getting that random.

  • It's like, OK, I'm just throwing stuff at random.

  • I'm making guesses of this.

  • And it was, like, one in three right.

  • As we continue, we'll see that it's actually

  • getting more and more accurate.

  • The second time around, it's now 53% accurate.

  • And as it continues, it will get more and more accurate.

  • But I'm going to switch back to the slides

  • and explain what it's doing before we get back

  • to see that finish.

  • Can we go back to the slides, please?

  • OK.

  • So the code to be able to write something like this

  • looks like this.