Hard Parts of AI: Neural Networks

Validating Pixel Data Neural Network

Will Sentance
Codesmith
Hard Parts of AI: Neural Networks

Lesson Description

The "Validating Pixel Data Neural Network" Lesson is part of the full, Hard Parts of AI: Neural Networks course featured in this preview video. Here's what you'd learn in this lesson:

Will adds an additional sample to the population to revalidate the neural network's accuracy. The results are incorrect, leading to the conclusion that "weights" are required to ensure the model understands which pixels are relevant to the conversion and their relative importance.

Preview
Close

Transcript from the "Validating Pixel Data Neural Network" Lesson

[00:00:00]
>> Will Sentance: So let's validate with some more images. Let's come up with another image here in our validation set of data. You're all doing really, really well, people. We're one step away from gradient descent, one of the most important aspects of training a machine learning model. So validation, let's come up with another image, yeah, 101 000 000 111.

[00:00:31]
So we know what this is. This is, anyone think this is a smile? No, it doesn't look like a smile to me. So smile, what would be the value in our, we know what this is, we label this, validation is data, we wanna check whether we've not got too perfect for our weights for this sample.

[00:00:48]
And that it's a bit more generally applicable. We know we know this is not a smile, so smiles value, Ben, will be what?
>> Ben: -1.
>> Will Sentance: -1, spot on, there it is. Let's do some validation, people. Validation, 101 000 000 111, there it is. Is it a smile?

[00:01:10]
We know absolutely it's not. Let's apply our multipliers. Posh word for multipliers. Ben, given you said it and then didn't say it when I asked, Ben?
>> Ben: Embedded [INAUDIBLE].
>> Male speaker 1: Weights.
>> Will Sentance: Weights, see, that's what happens when you're passive-aggressive with somebody. They rightly go f you and say the wrong thing.

[00:01:34]
F is okay, isn't it? That's just a letter. All right, all right. Yeah, and I was, then it's been fantastic. So our weights are 000. Everyone together, 000?
>> 0 -1, 0, 1, 1, 0, 1.
>> Will Sentance: Do you know why we use tools like NumPy to deal with matrices in Python?

[00:01:59]
So we don't have to write all these out, of course, but we're on a blackboard, for some reason. Why would we be doing this on a blackboard? Well, because, as I said, I don't know how to use computers. And nobody can disprove that, because you've never seen me use a computer in the history, I don't love them.

[00:02:17]
I don't love them. All right, no, they're great. So there we go, let's apply it. Let's sum and multiply as our validation stage. Some old, I'm a bit worried, but let's look at our converted output, converted. And then our target output, we know this is not a smile, so the target output everyone, is what?

[00:02:39]
>> -1.
>> Will Sentance: -1, thank you for the -1 as well, exactly. Accuracy is gonna be out of 1. That's what we're checking, out of this one sample. Okay, let's do our conversion. Kayla, if you don't mind, 0 by 1 is?
>> Kayla: 0.
>> Will Sentance: So just keep me going.

[00:02:57]
0 plus?
>> Kayla: 0.
>> Will Sentance: Plus?
>> Kayla: 0.
>> Will Sentance: Plus?
>> Kayla: 0.
>> Will Sentance: Okay, yeah, and then 0 + 0 +
>> Kayla: I guess, 0.
>> Will Sentance: [LAUGH All right, so you guys are [INAUDIBLE]. Okay, now, so 0 by 0 is 0, 0 by my -1 is 0. I'm a bit worried.

[00:03:22]
It's already looking worrying for my validation success. 0 by 0, okay. 0 by 1, everybody?
>> 0.
>> Will Sentance: 1 by 1. 0 by 1, so our total is, everyone?.
>> 1.
>> Will Sentance: Is 1 equal to -1?
>> Ben: No.
>> Will Sentance: No, it's not. So our accuracy is 0 out of 1.

[00:03:47]
So it's failed our validation stage, why? Because more pixels appear to matter than perhaps we thought. Which pixels here? It's kind of fun to try and spot. Which pixels here meant that this didn't work as we expected? Which pixels were previously 1s and are now 0s? Which pixels didn't we not realize mattered?

[00:04:09]
>> Male speaker 1: 7 and 9.
>> Will Sentance: 123456, yeah, 7, yeah, yeah, well, 6, yeah.
>> [LAUGH]
>> Will Sentance: 012, yeah, anyway, these two, yeah, exactly. These ones matter, didn't they? And we have, any multipliers or weights on those, Jamie? No, Jamie's right. Exactly, we do not. More pixels matter than we thought, so our multipliers are no longer effective.

[00:04:37]
Our accuracy dropped, we need to expand our sample. I'd say we just take this straight in, we don't use this validation. We take it straight in and make it part of our sample and add more multipliers now for more, maybe all of our pixels. In fact, we're gonna have a problem emerge where there is no set of perfect multipliers for even a sample larger than a few elements?

[00:05:06]
No, I hate the word elements, even a sample for more than a few images, we are not gonna be able to find a set of multipliers that will perfectly match. Meaning, maybe we introduce an idea of confidence, but maybe there's even a way of moving beyond, as you say, the fairly arbitrary nature of 1 and -1 to something more like 0 to 1.

[00:05:27]
Where 0 represents complete confidence is not, and 100%/1 represents complete confidence it is. And that is exactly what we're gonna do with the help of the Sigmoid activation function.
>> Paul: What's the difference between features and labels?
>> Will Sentance: Absolutely, the features are all the other data that we want to convert into the label.

[00:05:55]
The key thing is that in our sample we have every set of the pixels, in this case, the features are, actually, that's a great, let's just, before I go into that, shoot, thank you. Before I go into that, how many parameters do we have in this model?
>> Paul: 12.

[00:06:19]
>> Will Sentance: Paul, yeah, okay, [INAUDIBLE]. Yeah, 12 parameters. How many features do we have in this model? Last time we had four parameters and I guess, three features, although to be fair, you could say that the number of features kind of became a parameter in that model. So maybe that was three features, four parameters.

[00:06:40]
How many parameters do we have here? How many, sorry, features we have here, a bit simpler? Nick, how many features do we have?
>> Will Sentance: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, how many features do we have? 12 12, 12, features, exactly. Features are the input data that we have for both the sample and the population as a whole.

[00:07:09]
Meaning that, where we only have the label for those input pixels. So the features are these 12 pixels in their positions. You can literally store them as a list of an array, 12 numbers, 0s and 1s. We want to be able to take those 12 pixels. And for the data that we have labeled, the 12 pixels we have labeled 1 and the 12 we have labeled -1, work out how to convert those 12 pixels or features into their associated label.

[00:07:42]
Via the 12 parameters of our model, the 12 multipliers, that are 100% or towards that, convert our sample's pixels or, what are they called? Features, into the associated label, so that for our population as a whole, where we only have the 12 pixel values, we only have the features.

[00:08:11]
We can insert them and generate out a label automatically using the model and its parameters. What are the parameters here known as, everybody? Weights.
>> Female speaker 1: Weights, exactly.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Start a 7-Day Free Trial