Placeholder Image

字幕列表 影片播放

  • Oh, it's time.

  • It's time to fit our model.

  • Here we go.

  • So so far, you know, hopefully you've watched all the previous parts of the serious If you haven't, that's fine, too.

  • But what I have so far is I've prepared my data set, loaded it from a Jason file.

  • I've turned everything into 10 Tsar's.

  • And then I created a model TF using technology as a T F sequential model, which is designed to receive Archie be inputs and outputs a probability distribution for color labels.

  • And, you know, again, this is somewhat of a trivial scenario.

  • But I'm classifying data, simple data with just three guys all between 01 and nine.

  • Possible categories or labels.

  • Okay, so that's what I've done so far.

  • So now that I have, this is actually, like, always fears going over in, like, two seconds.

  • Not really.

  • All I need to do is call model dot fit so modeled off it.

  • Now, what do I need to pass to model dot Fit?

  • Well, the idea of model dot fit is that I'm saying, Hey, here's the training data here.

  • All the inputs and their associated target outputs, which I have called exes and wise.

  • Now, I think I'm gonna get an error right now.

  • Let me just actually run this, and I'm going to absolutely run this and see if I get the error that I'm expecting.

  • Yeah, so look at this.

  • Oh, okay.

  • So a couple of days, welcome to your life doing machine learning shaped mismatching.

  • I don't even expect this error.

  • You have to think about this one error when checking input expected dense input to have shaped three, but got array with shape 5643 3 So I guess I'm sending in not just three inputs.

  • The shape of my inputs is many s, so I think if I just do Uh huh.

  • So I made a mistake, and I used input dimensions where what I really meant was input shape.

  • All right, let's go look at the documentation and see what it says there.

  • And I actually, I've got pulled up already.

  • Okay.

  • So you could see what I specified was input dimensions.

  • Um, if specified defines input shape as bracket input dimensions.

  • Oh, So actually, I don't even need those that those array brackets there, and that should fix it.

  • There we go.

  • But if I wanted to use those a rape rockets because I'm sending in many data points, I could actually just specify the input shape directly.

  • And this would then have the array brackets around it.

  • So too subtle distinction, I think because only input dimensions is documented.

  • Let's use that one.

  • Let's put a three here.

  • Okay, So now you see, we've got the I wonder why that didn't go because I didn't call fit before.

  • Okay, so now I'm fitting the model.

  • I don't see an error.

  • Expected an error.

  • Let's.

  • So what happens when I fit the model?

  • Well, it returns a promise.

  • Modeled outfit returns a promise if you don't know what a promise is gets what?

  • I have a whole set of videos about what it promises.

  • I'm also gonna be using eventually awaiting a sink, which also videos about.

  • But right now, I can just right the dot Then a prom fit returns a promise which I can then call a function called then Thio, where the results will be passed in.

  • And I'm just going to say, uh, I'm gonna use this arrow syntax this Essex Aargh.

  • Syntax console dot Log results, and eventually I might want to do more with this, so I'm actually gonna make it a full function.

  • So this is what I'm saying is, once you fit the model, then log the results.

  • Let's see what happens.

  • Waiting.

  • Waiting up.

  • Okay, great.

  • Look at this history loss, and there's my loss.

  • So it fit that model.

  • It did one iPAQ and gave me a loss.

  • Great.

  • So done, train the model.

  • Here's the thing.

  • I want what I want to do.

  • Ultimately.

  • So this is actually, in a way, done.

  • What I wanna do is, first of all, I want to train the model for more than just one epoch.

  • So one thing that I need to do here is passed in some options, so I'm gonna create a variable called options.

  • And one thing I could specify is like pox.

  • I'm gonna say do it for 10 and then I'm gonna say, Let's actually let's just say to right now, it's gonna take a while.

  • So the third argument to modeled outfit is options.

  • And if I go into tension flow dot yes.

  • And I look for a model, don't fit because I was right there already.

  • We can see now.

  • These are the various options, and I'm gonna be using a bunch of these butt pox.

  • Is one of them the number of times to generate over the training data.

  • Um, so let's rub this now and you're gonna do I'm gonna I don't think we need all of this printing stuff.

  • So I'm gonna get rid of some of the earlier printing things because I don't need to look at all of that s o much.

  • So let's run, miss, uh, whips options is not defined.

  • I spelled that wrong.

  • I guess I still have 44 45 uh, console logging stuff, which I don't need.

  • E didn't get an error that I expect to get, Which is kind of interesting.

  • Um, and oh, you know why?

  • One thing that I want to do is I want an update.

  • You know, at the time of this recording, I think the most recent version of tension Flow Digest is 0.11 point seven.

  • Um, on when I was previously recording, I was using 0.4, and I think some things have changed.

  • All right, so let's let this run its running for two box.

  • Right now, it's finished, and I could look at the history and I can see both lost so we can see the loss went down for the second.

  • IPAQ.

  • That's great.

  • Now let's run this over 10 pox and let's run this.

  • And let's just console log results Not lost by the way or what was it, is it results dot history dot loss might be that.

  • Let's look at what it is.

  • The history history dot loss.

  • Okay, so let's do this.

  • Let's I don't need that.

  • Let's go back here.

  • Hit, refresh and waiting.

  • I'm gonna edit out this waiting part.

  • Okay?

  • So look at this.

  • Over 10 box losses going down.

  • This is good.

  • This is what we want to see.

  • Now, here's the thing.

  • Wasn't using to calculate that walk home.

  • Well, there's so much to discuss.

  • I gotta get myself organized.

  • My thoughts here.

  • I want to hear.

  • I think maybe maybe I've done this video.

  • I'm really dr breaking this into lots of small parts.

  • And really, what I've done now is called model dot Fit with one single option.

  • The two things I need to do that are next One is I need to figure out what?

  • Getting that lot like what Data isn't using to communicate that loss, is it?

  • The training data didn't talk about testing data and validation Day.

  • That shouldn't be thinking about that.

  • It's a point I've gotta deal with that.

  • Number two is I would like to I The point of this is I'm in a p five sketch and I could say function, draw back ground zero, and I can run this.

  • But look at this.

  • It just is loading up there all the while while it's training, I've locked and don't have any ability to run an animation I want.

  • Once it finishes, I see the canvas.

  • I want the canvas to animate while its training.

  • And I want to see the loss over time.

  • I want to have that reported back to me.

  • So those are the two things that I need to do.

  • I think I can tackle but training the testing and validation data thing right now because let's do that in this video, and I'm gonna add the animation stuff in the next video.

  • So first of all, Okay, so I have my data set.

  • My data set has I think was 5643 elements.

  • Data points in it.

  • I said at the very beginning of this series was preparing the data set that a typical thing to do is divide the data.

  • And again, this is really small for proper machine learning model robust.

  • I probably want to have a much larger data sets that this will actually kind of work just fine.

  • As we'll see, I want to use probably the 80 20 rule saying that 80% is actually the training data.

  • So I wanted just only use What is it?

  • It's because the keyboard is extra.

  • This I want Thio.

  • I want these X's and y's toe on.

  • Lee actually be 80% of that original data, so I'm not doing that.

  • Maybe I'll add that in another point.

  • That could be an exercise for you, of the for us, the viewer to take out 20% or me because my data set so small.

  • Just take up 10% of the data.

  • So that's what would be used to test the model after I finished training it.

  • But while I'm training it while I'm actually trading in figuring out well, how many input notes I want?

  • What learning rate do I want?

  • What are these sort of caper parameters?

  • What are the parameters of this system that I want to try different things?

  • How many pockets I want to train the model for what?

  • What batch size do I want to use?

  • All these things are known as hyper parameters, the parameters of the during the training process.

  • If I want to be playing around with those, I need a separate data set to computer loss.

  • That's not part of the training data, but also is not part of my testing data that we use when I'm completely done training.

  • That's what the validation data is.

  • The validation data is basically a test data set, but it's not your test data set when you're done and you're ready to publish your model.

  • It's your test dates that while you're doing all the training intensively, that Jess has a configuration options for modeled outfit that just says, Hey, use this much as the validation data.

  • So let's go back over here.

  • Let's go back to the documentation and we can see here now.

  • I could specify the validation data or I could just specify validation Split, which is a float between zero and one.

  • It's the fraction of the training data to be used as the validation data.

  • So if I come back here and I just add an option validation data, I say 10.1.

  • I want to use 10% of my training data as the validation data.

  • That's what's going to be used to calculate the loss.

  • But it's not part of the train down now.

  • There might be an issue.

  • I also want to make sure I have Shuffle on Shuffle is a parameter that shuffles the trading data at each epoch because you don't always want to train with the data in the same order as you're tweaking all the weights and stuff as it's doing.

  • Its training, if it's in a different order, is gonna help it out.

  • But the validation data I think I looked at this before, is before selected before shuffling.

  • So it's a lecture from the last sample, so I might have a slight issue, or if for some reason, the order my data is in, there's something weird about the end of it is all one label or something probably shuffle it myself manually.

  • But let's not worry about that right now that something definitely to be conscious off.

  • Well, this is so much to think about.

  • All right, now.

  • So now that we've added shuffle and we've added, um, but 10% is validation data.

  • Let me Now, run this again.

  • Okay.

  • Uh, so we finished.

  • Trained now with the validation split and oh, breaking news breaking.

  • Getting information from the chat that I wrote.

  • Validation data here.

  • Interesting.

  • Give me an error.

  • So if I wanted to give it specific validation data, that's what I would use.

  • But I want to use validation.

  • Split.

  • Thank you for to the chat for correcting me there.

  • Let's try running this again.

  • Let's give it Just bore a box a little bit more.

  • Time to wait.

  • Let's give it 50.

  • All right.

  • Okay, it's back.

  • Let's take a look at our lost function over 50 pox and we could see it's going way down to 0.75 You can see it's kind of stopping.

  • Actually, we kind of accidentally might if you could see how it kind of goes up now we could see like it's not able to get any better, so we might not even need 50 box.

  • But we might want to tune various parameters, but I'm not gonna worry about all that right now.

  • The point is, I have now trained the model using models outfit, shuffling the data with a certain validation, saving 10% for validation, not doing proper testing data yet.

  • That would come later and 50 bucks.

  • Okay, So, um, in the next video, what I want to do is make it so that I could run an animation.

  • I congrats.

  • The lost function over time, all that sort of stuff and not have it Kind of like blocking right the way it's doing right now.

  • Thea Animation Threat on.

  • Then, of course, I also need to allow the user to specify a color and get a label for that.

Oh, it's time.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

B1 中級

7.10:TensorFlow.js顏色分類器。訓練模型 (7.10: TensorFlow.js Color Classifier: Training the Model)

  • 3 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字