We're getting weights and biases. Then I need to weights and biases init.


Building a machine learning app | 10 hour coding livestream

Import wmb.


Let's get a lot of code on the screen and make it really fun face so we can get a thumbnail for this video.


Thumbnail. Like should we go hacker mode?


I need to find a thumbnail for this video so there we go. It looks like we're doing a lot of coding here. Thumbnail.


OK so we're going to get weights and biases working so we can compare two different models.


But now let's make sure all of this runs. Can we import weights and biases? Yes we can. OK.


So we want. How did they do that here?


Add a few lines to any TensorFlow script so weights and biases parameter dictionary.


Weights and biases TensorFlow guide.


What's this one saying? Can we use a functional API?


We still got images downloading and we still got plenty of time so this is this is where we're going.


Load files from drive.


OK I'm going to turn my screen off for a second while I log into weights and biases so just give me a moment.


Move this chair so we look professional. Let me log into weights and biases.


I'm just authorizing my weights and biases account.


Sony with GitHub.


OK.


I'm just logging into a.


Entering an API key here.


OK I think I've logged in. Let me just make sure that that's. Key is not there.


And stop this. Project equals. OK. Livestream. Modeling.


Oh yes team we're on.


OK so.


We've now got weights and biases up here. Let me just bring you back on. Welcome back.


Who was that one person who do I have any web or mobile development background? No I'm only machine learning.


One person who dislike the video.


Well we don't have that. Surely no one. Dislike this video.


OK. Weights and biases where are they using.


Next you import the weights and biases and net.


So.


That's what we want to do. Sink. Tensive ward.


Sink. Tensive ward. Yes.


We're on it.


Hey this is with TensorFlow one dude. Why are you using TensorFlow one?


Weights and biases sink. Tensive ward.


This is what I want TensorFlow.


Is this going to automatically log? If this automatically logs I'm done.


Let's find out together.


Hey.


Let's build the model.


Plot model so this is what's happening now.


Do we have include shapes?


TensorFlow Kerrers plot model.


Yes I'm going to be deploying.


I'm going to be deploying with TensorFlow light. TensorFlow JS.


Show shapes that's what we want.


There we go. So this is what happens. We have our images that go into efficient net. Efficient net outputs a feature vector of size twelve hundred eighty.


So that means that our efficient net model is going to turn every image that we put into it into a feature vector of twelve hundred eighty size.


So one big array of numbers.


That's one thousand two hundred eighty numbers long then we're going to global average pull that to condense it to a single vector smaller vector which is this the output of that.


And then we're going to condense that again into another output vector of shape one.


But I feel like we could have another layer in here.


That's all right. We're going to condense it all. We'll see how the model trains.


First. So let's compile.


This will be interesting. Will weights and biases track this?


If it does I'll be interested. I'll be very surprised. We're still downloading images. We are still downloading images.


Compile model. Model dot compile loss equals TF Kerrers.


Losses. We want binary cross entropy because we're doing a binary function.


Model one. We need an output function output activation. That's what we're missing.


I thought we were missing something. Sigmoid. Did someone miss that? Did someone get that?


Activation equals sigmoid. Model dot compile optimizer.


We're going to use our faithful atom. TF Kerrers optimizers dot atom.


Learning rate can be the default. And metrics equals loss.


No. Accuracy. That's all we want.


What's. Why is metrics getting angry?


Ah. Now let's fit the model.


History one equals model one dot fit. We're going to fit on the train data.


How many epochs? Let's do 25 epochs.


It's going to go pretty quickly but we'll use early stopping.


Create early stopping callback.


Now what we want to do is make sure.


So early stopping means that once our model starts to get worse it's going to stop.


So patience equals five. If it doesn't improve on metric.


Monitor. I believe it is. Monitor equals. If it doesn't improve on the val loss.


Validation set. Oh we're not going to have a validation set are we?


If it doesn't improve it's loss. Do we have a validation set?


Yeah we do. We will. We'll validate on the test data.


Epochs equals 25. Validation data.


So our model is going to train on the training data. It's going to validate.


So it learns on the training data and then it tests itself on the validation data or the test data.


That's why we created a trainer test set.


So let's go test data.


And then we want to go callbacks equals early stopping.


Who's ready to fit the first model?


Will this. If this. I don't know if this is going to upload to weights and biases.


Actually let's give this a model name.


Name equals efficient net.


Compile. Epochs.


Let's go 50.


Ready? 3, 2, 1, fit.


Oh we get an error. What did we get wrong here?


Oh my goodness.


Look at this. Input zero is incompatible with layer efficient net.


Expected shape. What is this?


Oh. Who caught that?


Of course it was me coding that wrong. We're fitting.


Okay. First model. Timestamp. First model. Timestamp. First model.


Oh. TensorFlow's out. Look how fast this is going.


Done. Okay. Our model is performing at 100% accuracy.


So that is insane. Model one dot evaluate.


Test data. Okay. Our model performs at 100% accuracy.


Great. We've built a first model. How goes that team?


What would you do in situations where you're absolutely stuck with two to three things with the same deadline?


So I would, do I need to use, yeah, dot log for weights and biases. You're right.


But there's no clear statement here that tells me how to use a log.


How do I turn off these warnings?


Please don't give me so many updates. Look at that.


Okay. The GPU is very quick.


Okay. 95% accuracy. That's pretty darn good. I'm happy with that.


Weights and biases.


We've built a test model. How good is that?


Let's get TensorBoard logs.


You go to learn tensorflow.io. It's a book.


When I'm stuck for different things, I would just pick one. Focus on one.


Create TensorFlow callback. I knew I had one of these.


So we're going to copy this.


Oh my goodness. Why does it do that every time?


So now we're going to import helper functions.


We can delete helper functions one. Are we still downloading data? Oh, the data is finished.


We've got food images. We've got images, people. We can start to build a bigger model.


So now we're going to do that in a second. We've got to finish. We're going to get weights and biases logging up here.


Still nothing here.


Callback.


Der name, target der.


Experiments equals let's do create a dictionary.


I think this might work.


Is that how I do it?


So this is why you write a book so you can come back and reference your own code.


Thank you. Yes, please. Oh, it's snack time. Did the timer go off?


OK, here we go. This is how we're going to get TensorBoard logs.


OK.


Let's see if this works.


OK, how did this go? Did this log into weights and biases?


OK, we got a warning from weights and biases when using several event logs.


So now let's go here.


Weights and biases.


You need a better guide here. Weights and biases, sync TensorBoard.


Don't just tell me to write sync TensorBoard.


Sync TensorBoard equals true.


TensorBoard.


There we go. OK, we're on.


OK, now we can try a FissionNet v2, but now we need a bigger data set.


OK, we've got more data. This is exciting.


Hey, the cadena, what's going on?


I am working on building a machine learning application called Food Not Food.


And you can find the GitHub code there.


We're building a machine learning model and we're going to deploy it.


Using TensorFlow and we've downloaded a data set.


That's what we spent the past five hours doing is downloading a data set.


So now we've got data image net images.


We need to split our images into food and non-food images.


So how about we do that?


And I'm sick of getting all these TensorFlow warnings.


Let's go logs.


Yes.


Now I wonder now because we've got TensorBoard up and running.


If we load our data and build another model.


Will this upload to TensorBoard?


Because we've got TensorBoard running here.


I want to make it. I want to make it with you.


Hey, we're on.


There we go. Okay. Look at this.


GPU. Yes.


Will this work?


If we can't get it to work, I'm just going to.


Now, is this going to be on ways and biases?


Okay.


I'll be back in a sec.


I actually don't know.


I'm not using 2.7.


I actually don't know why this is not working.


Ways and biases.


Do I need to write a custom training loop?


I'm perplexed.


Let's just get into writing.


I thought we were going to be able to use weights and biases pretty easily, but it turns out.


I thought last time I used it, it was easy as pie.


That's what I'm missing. Log.


Will that work if I just say?


Hey, there we go. What was I missing before?


Okay, we've got some. We've got some reports here now.


Let's now do the same.


Oh, we've got a timer.


You know what that means. We've got 10 push ups, 10 squats, 10 kicks, 10 punches.


We're going to start building a big model because deployment needs to happen.


We're going to start building the model after this one sec.


10 squats.


10 kicks.


5 more.


10 punches.


Okay, time to build a big model.


Next thing we're going to do is just test. Well, EfficientNet V2 is not big enough.


The model is already performing too good on our small data set.


So let's now.


I think I need to call weights and biases in it.


Sync TensorBoard every time I run it.


But that's all right. Okay.


So now we need to merge a back kick for some variety.


We can get back kicks, baby.


Okay, so let's move the data.


So we need to copy these paths.


Now we need to filter out our. I'm going to sit down now.


Hello, I'm a very small version of myself and now I'm getting bigger and bigger.


Hello, I'm back.


Okay.


Now let's filter out ImageNet data sets.


So we did data exploration before that can be canned.


We need to start training a big model. We've got a small model.


Our modeling code works on a binary classification problem, which is what we want because we are doing food, not food binary classification.


And now we have a bajillion images.


Let's use them.


So timestamp.


We're going to filter the ImageNet images now.


Timestamp, we're filtering the images from ImageNet.


So let's now let's have a look. How many images do we have total?


OS walk and image files equals one.


OS for does sub does files in OS walk.


We're going to go into data and then ImageNet images.


We need to people we need to keep this on track.


Do I not have OS?


We're keeping this on track.


Now let's have a look. How many image files we have?


A thousand.


There's all the files that we have, but it's really a lot more than that.


So we want to append.


So.


Let's see how many images that we have.


We got a list of lists.


Where's our list code?


Sub list. I need to bring this back over here.


Hi, Adam. Welcome to the stream.


Can we implement PCA using TensorFlow GS? Probably. I'm pretty sure I've never done it.


TensorFlow JS is basically just a JavaScript version of TensorFlow.


Find sub list.


There we go.


We have 50,000 images, people. This is what's up.


Let's do that. Let's let's build a we've got enough images to build a model.


Let's build a model.


So let's get the class names.


Image does.


Equals.


I want to move. I want to re fix this data set. So it's just.


We've got 50,000 images. Who's ready to build a big model?


LS clear.


Unless we're in data, we want to move data.


Image net images, image net images.


All to data image net images.


We've got a thousand different classes.


So now we've got image files and we are also going to get.


Image does equals.


Hey, what in that append sub does?


Hey.


So we have image does.


Okay, here's our classes.


And now what we need to do is.


We've got a big food list.


So.


Food class.


We've got a thousand.


9,999 different.


What is that?


Okay, now let's start filtering some data.


Give us the mullet haircut.


Hating to sleep. Alex. Thank you so much.


Thank you for joining in legend. Good night, my friend.


This is this is vs code.


Jupiter running Jupiter notebook. So now we need to.


Here's what we need to do. We need to move images from.


Data we need to make.


Train and test folders.


This is what we need.


This is what we need. We need data.


Train images.


And we need data.


Test how long we got left about 4 hours beautiful. That's exactly what we need.


Okay, and then this image inside here is going to be food images and non food images.


So let's do that.


We need to bring our model building code here.


I'm going to make a data splitting notebook.


So we want to turn this into.


Team we're on the up here. We've got we've got data. We've got model code. We've got everything that we need.


And then I'm going to clean this all up after the stream.


Okay.


Okay, don't run this cell because that's already run. However, we need to filter.


Okay, we want food.


Df food class name.


Gonna call this foodless filter.


Boom, baby.


Everybody.


Do some dancing.


Do some romancing.


Okay, now we need to split.


Our images from image net images into.


Move food images to food images folder.


So let's go here.


Image net downloaded image folders.


So these are the images that we have downloaded.


Equals.


Folder name. Lower for folder name.


I'm going to lower them all.


Lowered.


Done.


Get list of downloaded.


Image net.


Food images.


From image net.


To folder.


To.


Data.


Gaurav what's going on my friend.


Gaurav I use screen flow to record my course videos.


Okay, so we're gonna set another timer.


We forgot to set a timer team.


Okay, so.


Let's go.


Image folder in image net.


If.


If an image folder.


In.


Food list filter.


Oh, we're on here.


Figure out how to do it.


We're going to.


I'm going to call it image folder exists. Okay, it was true.


And.


Then we're going to.


No, we're going to make those of.


Desto equals OS.


Path.


Desto image folder.


Okay.


Oh, that's what I need to do as well.


Follow up tweet.


Say.


Actually did this.


Post.


OS start.


We're going to join the image folder.


Lister.


Hmm.


And then for.


Image to copy.


In images to copy.


Copy to.


I love re include.


Get the last one.


We'll print this out first print.


Okay.


Jesus. How are you?


Michelle. Thank you so much.


I appreciate it. Legend.


Ah.


Here we go.


Everybody.


Japanese.


I don't use.


Yeah, I'm a you could totally correct lowercase is an issue. But now there's this.


Hmm.


Hi, Sean. How are you? I don't use a Mac for training. No, I use a GPU.


What are we doing today? We're building a full stack machine learning application called food, not food.


You can find the code on GitHub.


And the notes on notion and all the code will be up there by the end of today.


So we're trying to copy some images.


What's happening here? Let's step back through the code.


Okay.


I see what's happened.


It's just stopping.


Need to bring the for loop out.


Strain.


Looks like it's coming back online.


Yes, thank you so much.


You're so right.


Back and back and back.


What do you reckon here?


Oh, did that just restart everything?


Oh, goodness. I'm going to have to rerun all of this code.


There we go.


We got it.


Thank you, Amar. I appreciate that.


My brother is still coding in Swift, so stay tuned for that.


But I don't know enough Swift.


Okay.


Why is this making a new


food images? Okay, this is what I want to delete.


So...


Thank you, Prateek. I appreciate that legend.


Ah, I see.


Thank you, Akash. I really appreciate it.


Okay, we need to copy all the images to here. I think we've got it now.


Why doesn't it make a new folder for Japanese?


There we go, team. Food images loaded, locked.


Now let's do non-food images.


Move food images from ImageNet. Download 2.


Now time to do the same for the non-food images.


There we go, team. Non-food images filling up.


Get out of that. Data splitting.


Okay, we're on.


101 food image dataset created from ImageNet or vice versa?


I'm not sure. I think food 101 wasn't created from ImageNet.


So now we're going to... It's still copying.


Okay.


Now...


We just want to extract...


We don't care about the classes. The class name is there.


So let's write down some pseudocode.


Move.


Extract food images.


Files and move to food images.


Do the same with test.


Okay, I'll be back.


I trained models on the cloud and I also trained models on my deep learning PC and Google Colab.


Background to white.


Some people ask for dark mode at the start of the stream.


So we switch to light mode for the rest of the stream.


Jeez.


What do you reckon? Light mode for the rest of the stream team?


Let me know in the chat.


Well, this is even... Wigging me out.


Okay. So now we have to move...


We just need to adjust this a little bit.


Let's get all the files in the food images.


So food image file paths equals OS...


R for do.


OS walk.


Light mode or nah?


We're going off light mode.


There we go. I got to use the dark mode.


Dot append files. And now let's have a look at...


We've literally spent five hours manipulating data.


That's all right.


Python get list of all files.


There we go.


Yeah.


Now, how many food images do we have?


2800. So we're going to need to pack that up.


We're going to need to bump those numbers up a bit for model building.


Any other opinions on the metaverse? No idea. I'm actually sort of not a fan.


I prefer the real world. Metaverse to me really doesn't have much appeal.


Okay, so now we want to just get the...


Copy this.


Let's randomly get a train and test. Split.


Okay.


Train and test done.


Yeah, I'm not a fan of the metaverse.


Or Facebook's version of it.


Just put it this way. Do you trust Facebook?


I know they renamed to meta, but do you trust Facebook?


Move to train and test.


We're going to take in a path of images. Target DIR.


Oh, man.


So it's going to loop through this.


Let's just rewrite this from scratch because I need some different logic here.


Oh, I need to get rid of.


I only want to copy.


Thank you so much. When is next machine learning monthly coming out?


Machine learning monthly is on hold for the time being while I make other videos because machine learning monthly is the videos only last like a week, then they are relevant, you know, so I want to make more longer lasting stuff.


Image file name.


Ah.


Okay.


There we go, team. We got this.


This could really be functionized, but we're just we're just hacking along here.


We need to get a model training.


What are we at seven hours? This is beautiful. We're about to get our first big dog model training.


Hey.


Hey, so ham what's going on?


We're building a model.


We're building a full stack machine learning application called food not food.


What's the time we're going on?


If you go to my GitHub.


Repos.


Food not food. You can see it there.


But we need to get this model built. Why is it taking me so long to split this data?


Let's function is this.


Thank you.


Thank you. Thank you.


Thank you. Going excellent.


What a role. What a role. Image file name. Oh my goodness. What do we need to do here? Target data equals food images.


We're on.


Oh, nice. Thank you.


There we go. We got images.


What in that work?


Okay.


Praise the Lord.


Okay, we're on. I know I've said that a lot, but we are actually on here. We can just do the same for.


There we go.


Okay, now we have two classes. Who's ready to build a big dog model?


We're back.


Time is going off.


Let's build a big dog model. Don't forget discounts alive. Go and see the discounts there.


Okay, model time.


I could do some movement. I got a mouthful of food.


But I'm ready to build a model.


Listen to that San Pellegrino.


This stream is not sponsored by San Pellegrino, but if they would like to, you know where to find me.


I'm going to finish my food first.


We have.


50,000 images, ladies and gentlemen, welcome to the stream.


50,000 downloaded images. Have a go at that.


43,000 training images, 10,000 testing images. We can, of course, upgrade it. The classes are a little bit imbalanced, but that's all right.


It's time to build a big, big, big, big, big, big, big dog model.


Who's ready? Okay, so.


This stream contains coding 30% and eating, drinking 70%.


5% kung fu, which speaking of which, we got.


We have some push ups and kicks and punches to do.


10 push ups, we're at the seven hour mark. Time to build a big model.


I don't know how long it is going to take to train, but we've got a big dog GPU down there and we're going to push it to the limit.


10 push ups.


What was the other one? 10 squats.


3, 4, 5, 6, 7, 8, 9, 10.


We've got some back kicks going, eh?


1, 2, 3, 4, 5, 6, left foot.


1, 2, 3, 4, 5, 6.


Okay, 10 punches. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.


Energy is back to me.


And now we are ready to build a model.


Let's go big dog model.


We'll start with an efficient net B0.


Or B2.


And let's see how long this is going to take.


Running.


And let's get a Nvidia SMI N watch.


How do you do?


Nvidia SMI watch.


That's it. Watch N1.


Nvidia SMI.


So this is the GPU. It's currently got all of its memory used.


Let's see if we run this big dog model.


What's it going to do?


Binary cross entropy.


Early stopping.


And we're going to train for some epochs.


How many epochs should we train for? Maybe start with 5 to see how long it's going to take.


Weights and biases not defined. We reset.


We reset weights and biases.


Who's ready to train?


Sync TensorBoard. Go.


Loading. Create TensorBoard callback is not defined.


Classic.


We're only really going to get...


There we go. We need to...


Let's train this model team.


Uploading data.


Watching Nvidia SMI.


Oh look how fast that's going.


The GPU is pumping.


Oh my gosh.


Already at an accuracy of 93%.


The Titan baby.


Look at the Titan loading. Okay, we can probably train for a few epochs here. Turns out.


Holy crap. Now this is fast.


This is on 50,000 images.


Mind you, the images have been already trained on.


Hey, what happened there?


Is weights and biases logging this?


Oh, we're training here. Look at this. We're training live. There we go.


Train. Step.


We've got epoch loss.


Compute. How's the compute going?


CPU. Where's the GPU utilization? There we go.


That's what we want to see.


80% GPU usage. GPU memory allocated. 99%.


Team, we're going good. Very good.


Validation. Training.


Have a go at that. Now, how do I add some panels here?


Yes, this is beautiful.


We've got a lot of warnings being pumped out here, but that's okay.


95% accuracy is pretty darn good.


Val accuracy is 95%.


Hey, Arturo, what's going on?


Hey, a couple of burpees just for fun. We'll do burpees next.


60 minutes.


Okay, look at this. This is beautiful.


We have GPU is pumping.


Actually putting the Titan to use case now. Okay, so we're looking at about 95% accuracy. That's good enough for me.


We do have a large class imbalance.


We're getting far too many warnings for my liking.


Elon Musk. Oh, thank you so much for tuning in.


I love what you're doing with Tesla.


There we go.


Training epoch accuracy is pushing towards 100%.


Doge man, the Doge man taking everyone to the Mars. Okay, look at the Titan just humming along like no tomorrow.


Let's get a model from this, hey?


We can save.


Save model.


Convert model to TF Lite.


Any resources there? Good morning from India. Hello.


You can start this. You need to know TF to build the model.


The GitHub is here.


Have we done five epochs yet?


How's our model going on the test data?


We got a model performing at 95% accuracy. That's enough for me.


But we


Let's go to length.


So we only have 2200 food images.


Versus


41000 non food images. So that's what we're going to have to fix up. We're going to have to increase.


Let's increase how many food images that we have. Food 101.


Can I get the food 101 data set in the house?


Should we do that or focus on deployment first?


Let's just get it working. Deployed version working and then we can build a


Then we can build a bigger model.


Got save food not food model V zero.


There we go. Now we can convert.


To TF Lite.


Food not food model V zero.


Saved model dirt. TF Lite converter.


Do we have a TensorFlow Lite model?


We have a TF Lite model ladies and gentlemen, let's do it. Let's see if we can get this deployed now.


So to get this model.


Do we have a timer running? Yes, we do.


OK, there's the weights and biases.


Let's now go to REPL.


Let's go food not food.


And delete.


So the classes for this will be one is.


Food. Two is not food, I think.


Let's check the order.


So we're going to use train data dot class names.


So right isn't the baseline accuracy already 95% due to imbalance? Yes, you're right.


We do need to fix this.


We'll fix it in a second.


Aman, thank you for that. And same same with you Arturo. Let's go class weights.


We can pass the class weights.


Where do we pass them?


Let's scale the weights.


Can you all see that?


It goes.


I'm going to scale the class for now because they're going to be different either way.


Yes, that's actually right.


One so it's going to be food, non food and then


total samples and then we go food samples.


So.


There we go.


Wait for zero is food.


Well, they're going to come in like that, aren't they?


Since we have


Arturo, thank you.


Hey, why is this?


Hey.


Shouldn't they add to one?


Now, what do we got? We've got class weights. Let's see how this influences the training run.


Sheik, welcome back. Good to see you, my friend. Class weights. So adjust for different numbers of classes.


So let's see how this adjusts. Do we have weights and biases tracking the history here?


No, thanks.


Okay, they're the only ones we want to look at.


We just want to look at Splendid Dream.


Let's upload weights and biases.


Okay, we're going nice and fast here, team.


The Titan, Sheik, have a go at this. The Titan is training like a beast.


So let's see where we can go.


We've got different darkness, six and Splendid Dream. We want to see which one does better. Does the class weight affect how our model is training?


Let's put a note in here.


Yes, the class weight is changing it. It's not as performing as good.


But that's what we want. Wonderful. Okay, so this model is going to be a bit more robust.


And the metrics, the metrics are more aligned with how the model is actually going.


I'll be back.


Okay, so this is much more reflective of how we're going to be training.


Much more reflective of how our model is going. I think we need some more food images.


So,


we're getting about 80% accuracy. That's all right.


Yogesh, how are you?


Faraz, how are you? What do you mean by basics? TensorFlow course? The modeling is not too advanced. Collecting the data, we went through a fair bit to get the data.


Because this is a custom project, so we don't necessarily have a data set ready to go.


Now let's start comparing the models. Yeah, see.


Splendid dream was overfitting because we didn't adjust the class weight.


Now different darkness.


I think we need more images of food.


Isn't it fun just to watch models train?


Who wants to just sit here and watch this model train for a couple of minutes?


No, we have things to do. So this is probably going to be our model.


Training at a very good rate, about a minute per epoch, because the class weight is adjusting the training time.


Yeah, we're getting a lot of warnings here. I'd like to turn them off permanently because they're distracting. So we're getting about 80% accuracy, which is pretty good.


And it's adjusted for the class imbalance. So let's, let's save the model.


And then we'll get it converted to TF Lite.


Will you be able to fast and stream for 10 hours? I've already had some food in this stream.


And I've been drinking tea and whatnot.


But I could probably fast and stream for 10 hours. Yeah.


Let's go to.


Let's get another terminal.


Unless we want to upload our food.


Gs util. Do I have Gs util here?


Clear. Let's create another bucket.


So I'm going to upload my model to Google storage and we have done six, seven hours.


We've got just over two hours left, team. This is beautiful.


So we've got two hours left to deploy a model.


Easy money.


Console.


So I'm going to create a bucket.


So if you haven't used Google Cloud, that's OK.


Create bucket and let's call this food vision.


Food, not food.


Or actually, I'm going to call I'm going to use one of my existing buckets so we don't have model playground.


Food vision model playground.


Continue.


I'm creating a Google storage bucket because that way we can host our model on Google storage, which will be very good.


Now I can upload this to food vision model playground.


OK, LS. We're going to upload this using Google storage.


So Gs util.


Copy food, not food.


You're starting to see how we could script this up.


V1.tf line.


Gs.


So we've got a 15 megabyte model.


I reckon we can get that smaller.


Who thinks we could get that smaller?


We should probably do that with TensorFlow Lite model.


TF Lite model maker.


Because we're using the full scale efficient net.


We might want to use efficient net light.


OK, so let's get that model.


Thank you, Kevin. I appreciate that. I think we can do it.


Let's get a smaller model building.


Ashique, you're pretty confused with the Google bucket.


So the Google bucket is literally just a hard drive on the Internet.


So rather than me going, hey, I've got this model on my local machine and every time you go to a website, like say on your phone and the website going to try and query my local machine.


We store it on a cloud storage provider so that because there's so many they have so many data centers around, it's a lot.


It loads a lot faster to whatever device you're using.


So rather than relying on my server here or my hard disk to upload something to the Internet and then you take it, which you could do.


We upload it to a centralized system and then that way that centralized system is able to load the model faster.


So, yeah, that's the main reason we do that.


But let's, uh, let's now.


We're going to build a smaller model in a second.


So we should have a model here.


There we go. Food not for food model. So it's 15 megabytes, which is probably too big for me.


Under 10 megabytes is probably better, but we're going to make this public.


Public can read it.


So now you should be able to download this this model.


So if we go to Colab.


And this is what I mean, this is the reason it's public now.


So you should be able to. The reason why we make it public is so that if someone visits a website and say food not food dot app, which is what we're building, they can download it like this.


W get to the website when you visit it through not food dot app is going to download the model just like that.


See how quickly that downloaded. That's that's the power of storing it on Google.


And Amazon S3 is much the same.


I think Azure call it blob storage or something like that.


But that's generally what you want.


So the way this is going to work is we now have we've downloaded a data set.


We've built a model. Now it's up to up to the deployment part.


So timestamp model deployment.


Let's go here. We've collected a data set. We've modeled the data set. We need to build the application. We're going to do both of these at the same time.


Build and deploy. We could deploy with Gradio.


Yes, you got to pay attention to the data set.


Yes, you got to pay for Google storage buckets, but Google storage is very cheap.


Let's have a look at this. Google storage pricing.


Look at this cloud storage. Storage is cheap online. Compute is what costs you.


Pricing tables. Look at this per gigabyte per month.


So what's our model is 15 megabytes. So it's not even standard storage.


Our model is 15 megabytes. So divide that by 100. So it's costing us two cents a month to store this model.


You will pay some transfer fees. So when the model loads. But that's again pretty small.


So right now it's costing us less than two cents per month.


That makes sense.


Oh, less than two cents per month because that is two cents per month, two cents per gigabyte.


So that's that's what you need to know about Google storage.


So now it's public, but we also do need to change the cause setting.


So this is something I ran into the other day. Cause setting.


Cause policy Google storage buckets. So cross origin resource sharing.


So excuse me, too many bubbles in the San Pellegrino.


So if you think about this from a security perspective, if we if I just made this file public and yes, you can download it.


But what if someone wants to use that maliciously?


So what cause does is I can set my bucket cause so that if you try to load this model in your own website,


it won't actually work for you because I haven't approved it.


So even though it's public, you can download it using W get, but you won't be able to load it in a website.


Let me give you an example of that. So we're going to start coding an app.


Food, not food.


We want this.


Classes, I'm going to get rid of that.


Delete.


So this is some code here.


To download a model and run inference with TensorFlow JS.


So this is the only stuff I'm not skilled in JavaScript, so this is what I prepared earlier.


I'll leave links to where I got this from, but.


This is what's going to allow us to load TensorFlow JS.


Now if we get rid of this.


Model.


Let's now let's upload our other one before we.


Upload file.


Code.


Oh, that's right. Food, not food is not local. LS.


Yes, we can do this actually. So come back into here.


If we run this, look what's going to happen.


So TensorFlow JS is loaded. This is all this HTML does. Let me just step through this line by line.


TensorFlow. So let's call this food, food, not food.


Hello world.


This app will tell you if.


The image you upload is food or not.


Right, this is all it's going to do.


Watch this.


Kevin says JSD. Oh yes, Kevin, thank you so much. Well, I probably will have JS questions.


I need to learn more about JS. See, I'm a bit more on the ML side of things, but less knowledge.


Well, barely any knowledge about JS. Like it took me.


You don't know. You don't want to know how long this took me to figure out how to write this script of loading a model and then just creating a simple button to upload.


And an image took me a long time, but that's all right.


And we got JavaScript's important. OK, I'm going to step through the HTML code first because the way a website works is you have HTML code is going to structure things.


That's going to give you like the frame. It give you the title. It'll give you the text. It'll give you the button, whatnot.


CSS is style, so that'll give you colorful. Right now I've got no CSS, so hence this is just text on a page.


But that's my style. I'm just making literally the most bare bones app that I can.


And then the JavaScript is the logic behind it. So HTML structure, CSS style, JavaScript is the logic behind your website.


So what we want to do is the HTML. I'm just going to build it like with some plain text. Then the JavaScript is going to give us the opportunity to upload an image here.


Yeah, image uploading. And then the TensorFlow JS model, which will sorry, TensorFlow JS package will allow us to load our TensorFlow Lite model because TensorFlow JS is now compatible with TensorFlow Lite.


Could we load a full scale model in here using pure TensorFlow? Probably not. You probably want to. You do want to convert it to TensorFlow. Why?


Because TensorFlow JS is going to run directly in the browser. That means that our model is going to work rather than sending data to an API, which could be slow.


It's going to work directly on whatever device you're using in the browser. So it's going to work within Google Chrome.


It's going to work within Safari on an iPhone, whatever the browser is on an Android app. And yes, that's all it does.


That's it. It'll tell you. It'll use a computer vision machine learning model to. Does that make sense, Ashik?


Let me know if you have any questions to classify your image as food or not food.


So basically, if you want to learn, we could build it through an API.


But for me, that's not the best personal experience because people often have to wait to upload data and then it has to be computed somewhere else and it has to come back. Why not just do it on the device they're working with?


Run that.


And this is just a website.


That allows you to write code and have it quickly refreshed in the browser. We could do all this locally, but I'm just doing this on rebel. So.


There we go.


OK, now this is not going to. And now so if we go back through here, the HTML, we've got some upload image code. We have a label. We have an input. Input creates a button.


So now I can upload a file. Mushrooms.


There we go. Undefined.


Wonderful. Now it's going to be undefined because I just changed class names in here.


Food, not food.


And then we have predicted class and predicted probability. And now we also have a couple of script tags here. What this script tag here tells us to do is to load.


This is TensorFlow JS.


Right, so we load that from CDN.js deliver CDN is content delivery network. JS deliver is like to me, I understand it is like it's similar to pip in Python.


So JS delivers going to give us an MPM package, which is a node package. Is that correct, Kevin?


So it's like loading in pandas like pip install pandas.


For me, this is like pip install TensorFlow JS, but the JavaScript equivalent version of that. Then we do the same, but for TFJS, TF Lite.


So this is going to give us compatibility between TensorFlow JS and TF Lite because that was a recent upgrade in TensorFlow.


And now TF Lite models work with TFJS or supposedly they do.


And so the reason why this model works is because we've got TF Lite there.


So we've got this here, but if we wanted it to load from the website, Google storage, we could put in a URL there.


So now let's do that.


OK, so MPM, I don't know what MPM stands for, but Kevin saying that MPM host JavaScript scripts as well as.


Packages, so not necessarily pure node. So now let's try to load the model in from.


I want to. Maybe we go to terminal. I want to download it.


So W get do I have W get installed?


Let's just get it.


OK, we've got the model now.


I want to just give you an example of what's going to happen.


So we downloaded the model. This is just the same model that we hosted in Google storage.


Come on, man. So we've got our TensorFlow Lite model here.


We've just trained that. So now there's the same one in Google storage. If we want to copy the URL, we can do that.


Go back to the report. Can that can that can that we do need to update the cross region origin policy.


So look, there's the model code.


Right. But if we add the model in here. Let's see if this works.


Upload file.


Downloads on a code. Food, not food.


We just want to get this working and then we can go on from there.


Could I learn to do deep learning projects without very expensive machine? Yes, you can. You can use Google Colab for free.


MPM is like Pip.


Yeah, yarn is basically a wrapper for MPM.


So now we have food, not food model.


Which is not going to open, of course, because it's a TF Lite model. I'm not even sure what that structure is.


But now let's load in this.


We'll copy the path.


So we want.


Food.


Not food model.


B1. TF Lite.


So let's see if it loads the model.


Model loaded. Look at that team.


Who's ready?


Who's ready to test out the model?


Yeah, so you can definitely start just start with Google Colab and Kaggle.


So we've got the model.


Food, not food. Can H1 tags have emojis?


Let's go burger.


Or burger.


No.


Run.


Model loaded. OK, we need to fire. Let's get a random.


What should we try?


Truck.


Image of a truck.


Let's go.


Truck is our sanity test. Oh, and we had the beautiful food that Georgia cooked us before.


So I'm going to use that as the sanity test to see if this works.


Truck dot JPEG.


Upload image.


We want desktop.


Hey, where'd that truck file go?


Desktop.


Truck dot JPEG. We're on. Let's see.


Script error. Oh, what did we get wrong? Undefined.


Converting int to float 32.


The bottom truck.


This one.


Oh, apparently, yeah, Ford have released a new truck that's electric. I heard about that.


So we've got a script error.


What happens if we can this?


And upload our truck image.


Do we still have a script error?


OK, that works.


OK, we're getting script error for this one, so there's probably something wrong here.


We're not getting any outputs when we change the model.


Run.


What outputs do we get here? Truck.


I think the image will be our issue will be here.


Let's console log something here.


We're going to this is so this is the input output type. So the error we've got here is that our model is I'm pretty sure our model is not accepting the right type of data.


In 32.


So we're getting an error here.


Undefined.


Don't cast in 32.


Thank you, Mintanchu.


Hatan, you slept and you come back.


I have just woken up to start the day and I still can't believe the goat is still riding. I'm still here.


Hey, hey, hey.


Script error, so we're getting something wrong here. Let's let's console log the image.


What is our image look like?


We're doing some pre-processing code now.


OK.


Float 32.


You can learn. You don't need to do a masters for machine learning.


You can learn it online yourself. That's how I got started.


But of course, like it's up to you. Do you learn better on your own or do you learn better in an environment?


So shape is 2, D type is float 32.


So we're troubleshooting our model here.


I might if I still don't if I don't get it correct, we're going to download.


Let's look at this TensorFlow Lite model inputs.


Objective C.


So.


TF Lite converter.


Yes, I did.


Metancho, I did I did change the labels here.


Food, not food.


I don't want to log the array image sync.


Console log image.


So we have a script error in 32. Where's in 32 coming from?


So image is float 32.


But the model requires.


Converting float 32 to float 32.


Whereas.


If we use the other model.


Floating int.


What D type is required by this model? I thought it was float float 32.


Let's try float 32.


Script error.


What input does TensorFlow Lite model take?


Hmm.


So we go back to the model training code.


TF float 32.


Efficient net model input type is float 32.


So let's go back. 420. We're going to.


420 baby.


The model is erroring on the predict function.


Hello from Madagascar. Hello.


Mitan Shu you're so right. The Neutrify app required you in 8. That's why the image was casted TensorFlow.


Maybe I trained the model in the same way.


But this is yeah, this is strange because see how the D type comes in here. I'm not sure why the predict function didn't work.


TF Lite converter.


How to check input type to TF Lite model.


Uploaded model.


Let's upload a model here.


We're going to check what our input type is here.


Food vision food not food.


Here we go.


This is a cool website.


Float 32.


Oh, we're on.


Shaking basket. I thank you so much. You're a fantastic help.


Remove all pre-processing steps in the error messages should say what shape the data is required.


Handstand push up time.


We got someone else moving in here with us.


Shape.


We choose another file.


So the model model is buckling on the


script error.


And then


you


Undefined. So the output is what's buckling.


Okay we're gonna move. We're gonna try that in a second.


Alright push-ups time.


You finished. Well done. We're gonna do star jumps instead of squat this time.


Georgia just finished her last assessment. Well done Georgia.


But we've still got just under two hours left. If this doesn't work we're going back to the TensorFlow light model maker.


Ten punches. We'll finish off. Maybe another five with this.


Okay.


One backflip at the 10 hour mark. Okay.


Alright let's get this deployed.


See we're running into a lot of image processing errors.


Did my internet just buckle out?


Oh no.


Okay we can't log the model.


Jake what's going on my friend?


Yeah the shape's supposed to be. If we have a look at the image shape it gets reshaped here.


So if we upload.


The image gets shaped into that. I don't know what's going on there.


Okay we're going back down.


Let me know when you're going.


I'm not sure what's going on. Let's try to recreate the same model.


It's time to move on because if we want to get this deployed before the stream's over.


We need to try and train it in a different way. There's something going on with the predict function which I don't know what.


But let's get rid of the truck. Get rid of this.


Oh wait what was that?


Load and run.


Okay let's try to.


Okay let's try to run this.


Test run tf.


Light model and if it doesn't work we're going to go with the TensorFlow light model maker.


Test run.


Undefined. Just print the output.


You're so right but I'm trying to here.


Let's see.


It's buckling. The model's not taking the predicted image in some way shape or form.


Thank you.


Wow it's working here.


You rocking?


Okay let's input details.


It takes shape negative one.


D type int 32.


Int 32 let's try that.


Did we try that already?


Last commit was a while ago but I'm going to commit it all at the end.


Converting int 32 to float 32.


Why is it converting int 32 to float 32?


Last commit. Let's commit some code.


No need to cast.


But still we're getting some sort of error here.


Hey Matachu.


What do you think's going on here?


We get an int 32 error.


Script error. It's happening at the predict function. It's breaking here.


Console let's log this.


Model about.


There's something going on with the function here. Let's try another model.


Let's get more data.


It's breaking at the predict function.


Let's use TensorFlow Lite Model Maker to train a bigger model.


I'm pretty sure that'll work.


Get another script.


We want food 101.


I think I have it stored in the


TF course.


Food vision.


All classes.


Let's go here.


Okay, we're downloading more images.


In the meantime, we're going to build


small model.


We're going to use the model.


We're going to build small model.


We need to turn these TensorFlow warnings off.


While we're downloading some more, let's build a model with TensorFlow Lite


Model Maker.


This is some code I prepared earlier.


Okay, so let's, this date is almost down though.


You could probably wrap it in a try and accept.


Guys I really appreciate the help by the way.


Thank you so much.


I'm still perplexed.


You in 32 you reckon.


Jake programming says convert to you in 32.


Let's see what happens.


Hey.


First error.


Alessandra what's going on?


Running image to.


So it broke there.


Oh, did I set the timer again?


Yes, I did.


Harry Prado.


What's going on?


So we're downloading.


We're downloading more food images to make the model better.


We're going to get this to work team.


Congrats on 100 K man.


Thank you so much.


TensorFlow please set your logging info to nothing.


What do we got wrong here?


Oh no, we've run into a CUDA error.


We've got more images.


Prit hello Sanskar how are you?


So does this still work?


Come on now.


Are you still there?


No, not yet.


Oh, I'm sorry.


Okay, we're training a model now with TensorFlow Lite Model Maker.


But now we're going to build a bigger data set.


So we have data.


I want to unzip.


Beautiful.


These are all images of food.


Maybe go to the bathroom and be back.


I love my ongoing usefulness.


The


Titan is going incredibly well. So we're inflating 100,000 food images here from the Food 101


data set. And we're also training another model. Now I'm using, I'm SSHing into my deep


learning PC which is downstairs. And I'm using that to compute. And it's taken a little while


now because we're doing too many things at once on the CPU. I'm going to get this image


ready. Look at the beautiful food that Georgia made for me earlier. This is our test image.


This is delicious food that Georgia made earlier. So big shout out to Georgia. Thank you. And


we're going to put this on the desktop. And we're going to call this food. We need to


open this up and export it. Food.jpg. There we go. This is our test. I'm all self-taught.


Yes Jake you're right. My JavaScript skills are terrible but my Python skills are pretty


good. If you want to go to find out what I did, I created my own AI masters degree. So


I just went through a whole bunch of online courses. That tells you a lot about me. And


then start AI ML is another one as well. That's how I got started. We've been doing ML for


about four years now. So we just unraveled 100,000 images. So let's upgrade the food


classes to get let's get an extra let's get an extra 20,000 data points or an extra 30,000.


Yeah, there we go. Okay, we're going to we're going to do this. We're going to do this very


quickly. We want to call this food not food model v2. That takes a little while to convert.


We're going to let that run for a bit. So we're going to go back to our other editor.


Hey, VS code. Let's open this. Let's go to food not food.


And then go add more food images.


Got more food images


to load.


Balancing the data sets.


So we want to


download it more data from food 101. Now to add


more food images to the model.


So let's


get list of food 101 images.


How's this going still exported? Oh, it's exported.


Team it's about to start raining here.


We're not leaving until this is deployed.


Load image.


TensorFlow


Keras load image.


Oh, don't


do that.


It predicted non food image more than food image.


That's not good.


Yeah, I wrote that


the heck Elon Musk doing here. Jake programming. Yeah, you're so right. I wrote that. Siraj


Ravaz a wizard. I wrote that when I first started to learn it. Since then, a few things


have changed. But when I first started to learn AI, Siraj did give me a lot of inspiration.


So we need more. We need more non food images. So that's what we're going to do. I haven't


done. Yeah, 2017. So that's when I started. So four years ago. And as you can see, things


change. But that's the beauty of having that article documented when it's documented.


LS. Okay, let's get


started. Subdirt once again, we're doing sir, is it a good way to solve text to text


NLP problems by doing one hot encoding? So no, I would create an embedding. So basal


ad wait, I'd look up hugging face. Hugging face NLP. Hugging face NLP course I do that.


Food image paths equals we need more food images people equals I finished milestone


one of TF course and want to do some small CFD projects. Should I do something from scratch


or use transfer learning? I'd try start from scratch first and then use transfer learning


to improve it. You'll probably find transfer learning works far better than from scratch.


So for file in files. Join.


There we go.


Next. 102,000 images beautiful.


BNB seems to apply differently on these ones.


How to remove.


I haven't created. We're not using image augmentation. No.


Do I have a plan to get a master's degree? No.


Have I created any course on Hugging Face? No. Use Hugging Face's standard course on their website.


I've lost some weight. Hope you're right. I've actually gained some weight.


I'm about 5 kilos heavier than I was at the start of the year now.


There we go. Food image paths. Let's get a random 10,000.


Get 30,000 images. That way we've got a balanced class set.


Import random. Random seed 42.


We need to create a bigger data set to build a bigger model.


Man, which data set am I using? I'm using a custom data set. One from ImageNet and one from Food101.


So let's go 30k random. Random 30k food image paths equals random.


Sample food image paths 30,000.


Okay, we have 30,000 more images or actually let's make it 35k. That way it's closer to.


What did we get for the different lengths of data sets?


Let's open up model building.


41,000. So let's get an extra 38,000.


So now we'll have 40,000 images of each.


Food and not food. Okay, now we want to.


So where did I do this? I did this in data splitting.


Data splitting.


I need to clean up this code. Don't worry. I'll clean it up after the stream.


There we go. Extra images.


Copy images to file image list target do.


Okay.


We just inflated our data set.


Copy three.


Okay, we're copying data set. There we go. We can now build another model.


Now we've got more testing data.


Beautiful.


We've got 80,000 nearly 100,000 total images now of food and not food.


Let's try in a model.


Here we go. Okay, this is taking a longer time.


This is beautiful.


Now let's go back to here. Add file.


Did I say food not food model V2?


There we go.


See how this is much smaller, this model, the V2 model.


But now we're also training another one.


A third one.


So the model made with TensorFlow Lite model maker is a lot smaller.


Hey, did that not work?


Completed.


This is not the same project as a food vision project on ZTM course.


It's close, but not the same.


So see, we've reduced the model size here by 5x.


That's pretty good.


Now let's...


...we're going to upload the version 2 of the model.


And see how it goes predicting food not food.


Who's ready to go?


Who's ready to make a prediction?


Let's do a timestamp.


Timestamp for making a prediction with model V2.


We've tried again with the TensorFlow Lite model maker.


So this is a timestamp for version 2 of the model made with TensorFlow Lite model maker.


Let's run this.


Loaded the model.


Upload model.


We need...


Script error again.


There we go.


What did we get?


Truck here we go.


Prediction.


Food predicted probability 100%.


So I think our classes are back the front.


Because let's change this.


We got a prediction here team.


Look at this predicted class with the truck.


Now if we add up a photo of food.jpg.


Yes.


Okay.


We need is Softmax the right one to do?


Sigmoid.


TensorFlow.js. sigmoid.


TF. sigmoid.


How's our other model going?


But this is working.


The model is now working.


Look at this.


How exciting is this?


We've got too much going on here.


What is the sigmoid give us?


Undefined.


So let's go console log output values dot.


Food.


We got it working in the browser team.


How's the model code going here?


Okay, this is going better.


So let's go.


Benjamin Cullen.


What's going on?


Of course, I'm not giving up my friend.


We need to get this model deployed.


You need to get everything deployed.


Let's say version 3 of the model.


See if it works better.


Okay, so the output we want the arg max of 0.


Maybe get.


So we need to fix up the.


Output values dot arg max is not a function.


How do I get the arg max?


What happened just before?


TF arg max.


Okay, let's upload image model 3.


While we're here.


Much better.


So chicken wings works.


V3 is ready to go.


So let's load up mode upload model V3.


And we're almost we're almost there people were almost there.


TF arg max is not a function.


It's TF arg max.


We're getting closer.


So this is our array.


Oh, we're gonna move into the final hour.


But is our final model here.


So we need to move.


Okay, the final final countdown is on.


We have 10 push-ups for the final time.


We're going to do 10 lunges.


One two three four five six seven eight nine ten ten kicks.


One two back kick three I'm going to boot this chair across the room in a second four


five left one two three four five ten punches to finish off one two three four five six


seven eight nine ten.


Okay, let's keep Kevin you've been in here the whole time.


My boy legend dog.


Let's set one more timer.


We're going to finish this.


We are going to finish this this took longer than I thought.


Arg max okay, why can't we get the arg max of this?


Output values is not outputting.


However, we get the array sink output zero.


Let's try that.


Script error.


Let's block that out.


Fault log output.


It's output array sink array sink.


Output is not an array.


Mitanchu welcome back thank you.


Okay that's all right that can stay there.


But the output is now I want to get the array of arg max of this.


How do I calculate the.


Okay.


How do you turn this on the dark mode?


Wrap in tf arg max yeah I've got that here.


Output dot array sink.


Done.


Output values.


Hey there we go.


Halloween baby.


There we go arg max.


So now let's add the final model.


Not food okay there we go now we can start to adjust the code.


How much should we expect to earn from machine learning?


It really depends.


I have no idea.


So now let's get rid of this.


I don't want to log the output.


I want to get.


And I want to get I need to sigmoid this probably actually.


Let's try this.


Is it going to predict on food?


Food.


Yes.


Well there we go.


We finally predicted on food.


Okay now let's predict the let's get the probability.


Hey no this should be.


Output values should be if we go to.


Let's do TF soft max.


Output array sync.


And then we're going to go.


This equals dot arg max.


Dot array sync.


And thank you Matan Shu.


I appreciate it my legend.


And then we want output values max.


Let's run.


Choose file let's try truck.


It failed again.


Oh here we go.


Run.


Not food 100 percent.


There we go.


Time stamp.


Time stamp 100.


Now we're going to try it on one more image and that's the food.


Predicted class food 100 percent.


Oh baby.


There we go team.


Okay now let's get this onto.


GitHub.


So.


We got one final step we need to host it.


We need to host it.


How long do we have left.


942 OK can we get this hosted.


So let's get the cause policy set for our bucket.


So the cause policy allows us to download different things.


L.S. Do we have cause the chase on.


Hmm.


Let's go here.


I need to figure out where to which ML deploy is.


All my codes everywhere to which ML deploy there we go cause dot J.


So I don't want to open X code.


Now let's go code.


So we're going to make this available everywhere.


For an hour.


We got it loaded.


Pro tip unrelated use text content for in a text for performance.


Thank you Kevin.


So if I just go.


Oh baby.


Console log output values dot.


OK.


We still need to deploy the model so we need to update the cause settings of this bucket.


G.S.U. tools set cause of the cause allows us to download.


The model into different platforms.


Otherwise if we don't I'll show you what it's like without the cause Google storage set cause.


Set cause J.


So on file name bucket name.


So this is without setting the cause let me show you what happens if we have the model as a U.


R. L.


So we have the model here we've got the U.


If we go into our code let's get rid of some things.


So we want here.


If we load our model with instead of see how we loaded it with a string.


Because our model is available in the file format here we want to load it with a Google storage U.


Let's see what happens when we try to load it using a U. R. L.


Run we try to load the model it won't.


It'll fail to fetch see what I mean.


So that's what happens when we try to load the model.


From Google storage but of course we won't always have this available so that's why we have to set the cause now if we set the cause watch what happens.


Cause config.


J.


J. S. on G. S. We want to set it on this bucket.


So food vision model playground.


G. S. you till set cause cause set.


Now if you go G. S. you till.


Cause get.


And then G. S. the bucket.


It should have we can now do an hour worth of these requests.


From any origin with any response header.


So let's have a look at what this does now notice how just before we had this type error failed to fetch now this should work if we load it from here.


Run.


Might take a little bit to kick in.


Still failed to fetch.


I thought this was gonna work and it didn't work.


See how we've loaded TensorFlow J. S. but we haven't loaded the model.


Wait.


Classic.


I thought this was going to work but now it doesn't that's all right.


We're going to switch ML deploy.


Make sure we've got the same set up here.


Type error.


But if I change this.


To this.


It gets it.


Let's try with a different photo.


Apple.


Predicted class not food.


Is it just fluking now.


Oh my gosh my brain is so fried right now food.


Predicted class food.


OK well it worked on that but now it's not uploading to.


I wonder if I get.


This model doesn't work.


Not one test.


We get the same error.


Twitch ML.


Last 10 minutes.


That's all right.


We're going to fix we're going to fix this we're going to get this done.


If I put that in there.


It doesn't load either.


Twenty four hour stream I'll be back.


For some reason.


It's not loading.


But that's all right we'll fix it up.


GSU till.


Why did I cut my facial hair.


I felt like it.


We're approaching the 10 hour mark and I'm not leaving until this is fixed.


I had this working at something very similar working.


Why did this fail to fetch.


I look like a boomer with a mustache.


J.S.


J.S. deliver.


I need this.


I don't think this will change anything but let's see if it changes anything.


I'm.


I've got the latest version here why is the cause not working.


Why is it all of a sudden have an issue when.


Let's try and get it on the cell and see what happens.


Download a zip.


I will get this working.


Let's just go to local actually local and we'll go.


Let's give him.


Copy the JavaScript into here.


But I actually want this form of JS.


We're just copying some stuff from some code I've already written.


But we're going to get this live.


We're going a little bit past 10 hours.


Now let's deploy and see what happens.


Oh wait, we need to add the model.


This is the beauty of TensorFlow Lite, the model is so small.


Add the US file, JS file. I didn't add the JS file.


You sure?


Ah, you're right.


Let's go to our trusty Vercel.


Look how easy this is to deploy now team.


Vercel.com, I don't want to create a team. I have my Git repo there. It's going to deploy.


Here we go. We should be deployed.


Woohoo. Let's open it up.


Food not food.


Model loaded.


Food.


Yeah.


Food. Oh, it only took us the entire stream to build, but it is live.


Timestamp, timestamp, timestamp the deployment. There we go.


Food not food. Vercel.app is live people.


Okay, now let's change the code a little.


I'm going to make it ls cause.


I'm going to change this to this URL.


Now this should be able to access.


We are live people. Fully deployed. Check it out.


Git.


gsutil cause set


cause config gs


We want our bucket to be


clear. And now let's change the script here to use the model from the URL and see what happens.


Git add script.js


Git update script to use


Oh shit. Git commit.


Update script to use tf.js tflite model from bucket.


Git push. Let's see if this does anything. Now we're going to do the real test. I need to get, let's do camera.


Yeah, I got a camera that's not food and I'll get some actual food and we'll see if we can compare.


Try it with a BK burger and it worked. Yes. Beautiful. So let me


see if it works. Still, I've just updated the bucket.


Is the model going to load from the bucket? I think we might have an issue here.


It's not loading from the bucket.


Awaiting tf.js model.


OK, so that's broken. I need to fix that, but that's all right. Let's get this out. It's deployed. If I don't deploy it from there, it's going to go git add script.js


Git commit revert back to using local


model file. Git push.


Oh, I didn't save that.


I need to add up the index HTML title is


food not food app.


Git add index HTML.


Update HTML title and model usage.


I just changed the title. I'm going to go get a.


I'm going to go get food. Be back.


So we have two options here.


We have some bananas and blueberries. As you can see, I'm going to take a photo of these.


The title of the web page should be updated now.


And then I have then I also have a camera. I'm going to take a photo of that.


So now let me just get those over to here.


Offloading it.


Downloads, date modified.


So here's my camera photo. I'm going to export that.


Camera dot jpeg into food not food.


And then here's my bananas and blueberries.


Bananas and blueberries.


Done done.


How's the app going? Is still working.


Where is it? Food not food.


Model is loaded. There you go. There's the app. So we're going to choose a file.


Food not food. We have camera.


Not food.


And then we have bananas and blueberries.


Oh no. Why is that not working?


Let's try it again.


Let's try another image of food that I know that food. Ten whole foods, train, banana.


Bananas.


Oh my goodness.


OK, so we need some actual food classes in the model.


Food.


So the model is not very good.


That's all right.


Let's try another class.


Egg.


OK, so I think it's getting the images. We need more food images. That's that's going to be the fix for this.


But that's enough for the stream.


Let's go here. I'm going to do one more thing. Oh, hello bananas.


It's making me very hungry. Hey, look at that mustache. Happy Movember everyone. I need to do one thing behind the scenes.


To really finish this app off.


If you've got any chat, if you want to have any questions, we've nearly we've nearly reached the end of it. Yeah, we've overfit. I've got to fix that, but that's all right.


We've got a simple model deployed.


Hey, Arunabha, how are you?


So I'm doing one thing that's going to just finish up.


Hot dog worked.


I need to.


Add some CSS to it, you can.


77 minutes.


If you want the 77 minutes stuff, you can see here.


I need advanced.


I'm just updating something. Give me one second.


I can't do this with my stuff on the screen.


I do roll Jiu Jitsu.


I love Jiu Jitsu.


Someone says my explanation is very crazy.


For my TensorFlow course, is that what you mean?


An ML engineer can be called a developer.


In my opinion, I do it a lot of I'm doing a lot of developing now.


Thank you, Ryan NG, I appreciate it being subscribed.


Thank you so much. My beautiful picture of cheese worked.


My computer's logging lagging.


Tell me if I'm still live.


Don't kick me off. It's right at the end.


Oh, my goodness.


Right when we want to start loading stuff.


Thank you. Thank you. I'm still live.


So the app is deployed.


And I believe it should also be.


So I'm back. Here we go.


I've just started the website.


Food not food dot app.


So I can't be loaded.


I think it's taken a little while to propagate.


But if you go to food not food dot app, it's live here.


Is this going to work on this?


It's food. Yeah, baby.


Food. Yeah. All right. It's working. OK. OK. We're good.


Food not food.


And let's try another one.


Food. Yes.


We are live. It's working for me.


Everyone, the apps working for you.


And then if we go to a new tab.


If we go to food not food dot app, what happens here?


Is it working on Safari food not food dot app?


Yo, Celine, what's going on?


I'm not sure why food not food dot app is not working.


Let me go off stream for one second. I'd like to finish the stream with this being live.


Might take about half an hour to.


Beef sample is strong.


A record.


OK.


Oh, my God. This is the most. Why is this not working?


Maybe it takes a little while to propagate through.


It's working.


Model loaded. There we go.


Beef. Is this food?


Food. Yeah, yeah, yeah, yeah.


Food.


OK, team, I think that's it works for you.


Food not food dot app.


Food not food dot app is working for you guys.


Can anyone confirm if food not food dot app is working?


Well, that's so strange. Thank you, Kevin, for tuning in. I really appreciate it. Let's go to food not food.


Not food dot app.


Kevin, thank you so much.


So this if you guys go to this website.


Food not food.


Dot app.


OK, I've got to load this. This is the final test.


Food not food dot app is not working, but the cell is working.


Can we confirm?


Can we confirm? Is this link working?


That link is working.


And food not food dot app. Is that working?


Is this link working?


Someone confirming me if we confirm that food not food is working in the chat, then we're done. Food not food dot app.


That is crazy.


It's not working for me on either device.


That is insane. OK, well, friends.


Thank you so much for tuning in to the 10 hour stream.


This was to celebrate.


For some reason, look, it's supposed to be working there, but it's not.


That's amazing.


We're all good.


I'm even trying to load it with mobile data on my iPhone and it's not working.


Let's try one more time.


We're trying Google Chrome on my iPhone with mobile data.


Paul is trying. Yes, food not food dot app lives.


Everyone go to food not food dot app and you will test to see if your food, your photos are of food or not.


That's all it does. Food not food.


OK, I now have a totally new browser on my phone.


Food not food dot app.


I cannot believe this. I'm going to try a different device.


Maybe the propagation to Australia is not working.


I love how everyone in the chat, everyone in the chat.


Is leave an issue on GitHub if it doesn't work for whatever food you're using.


It loaded. Yes.


I've got food not food dot app. Food not food baby.


There we go. OK, it's working on my iPad.


Is it going to work on my iPhone now? Because these are using cellular, by the way.


So food not food. This is what the 10 hours has been leading to.


Can confirm it's not working on an iPhone.


It's working on. It's working on. It's working.


OK, here we go. Let's test it on these bananas.


I think it doesn't like bananas. Use photo.


Food. Yes.


You can't see that. OK, I need to screenshot that.


And then one more, one more, one more.


And then I'll show you then. Then we're done. So this is a camera.


Use photo not food.


I'm going to screenshot that and then I'll just show you them on the screen because I don't know how to get this stuff on here, you know.


Share my iPhone screen.


Let's go to their food not food dot app.


This is the this is the real life test.


And all of you are using it, I'm so.


Banana is a must. So, yeah, please let me know if leave a GitHub issue, if there's any food you want and we'll make food not food work better.


But we got we got it working. Food vision is live, people. Food not food dot app.


Go and check out food not food dot app. We need to upload update the website with.


Food not food dot app.


Oh.


It is like it literally all it does is tell you that food not food.


Leave an issue if you want it fixed or if you want more foods added and we will work on that.


Right. We're changing the world. One food and one not food at a time.


There we go. We have confirmation to finish the stream off.


Please feel free if if you want to look at this food not food dot app.


Go and visit the website. Go and go and break it.


This is amazing. Thank you so much for tuning into the stream. We went we went all from the we went from building a data set to modeling the data set.


We build a data set from scratch. We build the application. We deployed the application with a live web app.


We could do Gradio. We could do an API. If you want to add some styles to the website, you could leave a pull request.


Please please do if if anyone adds any styles to the GitHub in a pull request, I will I will push those changes and you will be part of the food not food revolution.


OK, so if you want to style it, please style it. If you want to add some better JavaScript because my JavaScript skills are poor.


Please do make a pull request and I'll add it. But that is the 10 hour live stream.


Look at that. We've finished it off. Wow. OK, I need to go and chill out for a bit because I've been staring at a screen for 10 straight hours.


But thank you so much. There'll be plenty more. The video is going to live on live on YouTube forever.


But if you want to see future streams, I stream on Twitch as well.


And you can also see streams on my archive channel. But thank you so much to the 100000 people subscribe to this channel.


I really appreciate it. There is plenty more to come. So, yeah, if you want to add any code to the GitHub, go for it.


Otherwise, I'm out, people. Have a good night. Have a good day wherever you are in the world. And I'll see you next time.


3 Life Principles I Learned From Ray Dalio

Yo, what's going on y'all? You know what time it is, it's podcast time! So, sorry about that by the way, it's episode 108 of The Daniel Burke Show and we are at July 21st 2017. Happy birthday to Laura, shout out to Laura by the way.


But, what have we been up to today? Well, this morning I went to the dentist. I haven't been to the dentist in such a long time, but keep going to the dentist, otherwise it costs a lot of money. Like, I was going to be charged something like $400 for that one visit, but luckily health insurance covered that.


I've got to go back in a week's time for another visit. So, I haven't been to the dentist in maybe two or three years since getting my braces off. You'd think I'd keep my teeth in good condition. But, long story short, go to the dentist. That's number one tip for today.


Nah, just joking. We'll get into some better stuff. And if my face is all red and my hat, I mean sorry, my head has hat hair and whatnot, it's because I just went for a run. I haven't been able to train much this week because I went too hard at dodgeball and we lost.


I still managed to seize and tighten up a muscle in my shoulder. I can't really explain it to you, all I know is that it's slowly getting better over time with stretching. The other day I couldn't touch my chin or my chest. Even that was still a little bit painful.


But, enough about me. Let's get into the podcast, let's get into the show. What is today's show about? Well, as I mentioned a couple of episodes ago, maybe in 106, maybe in 107 as well, I've been reading Principles by Ray Dalio, which is a book or an essay that Ray Dalio originally wrote in 2011.


For those who don't know, Ray Dalio is the founder of Bridgewater Associates, which is a massive hedge fund based in the United States. His net worth is something around $16-17 billion and he's about 67 years old or something like that.


But, he wrote a book, wrote this principle scene to get down on paper what his most fundamental life principles were, what the benefits of having principles are in his opinion and his most fundamental management principles.


What he's learned essentially running Bridgewater and just generally throughout life. I suppose it's sort of really inspiring to me. Well, not inspiring, actually let's say inspiring but also encouraging to see people writing stuff like this down.


It's a law and it, I don't know, I take, how am I trying to say this? When I learn really well, when it's put into this sort of form. And so that's why I like reading these types of books, these self-help books or here's what I learned books because why spend all the time sort of learning something yourself?


Although that's a great way to learn, which is how I'm doing a lot of things, how we do a lot of things in life. But when you can accelerate your learning vicariously through others, right?


So the fact that he's put this into a book and sort of made it publicly available now is amazing, right? And I really appreciate that sort of stuff.


So like what the book that my phone is currently resting on recording this show is Tills of Titans by Tim Ferriss, right? So before last year, before 2016, I would hardly ever read books.


And since then I've only read maybe a hundred or so books and my learning has just gone up exponentially. And it took me a while to realise that but once I got into it, I'm addicted to learning.


Nonetheless, let's get back into it. Getting distracted going off on tangents. So I've got a whole bunch of highlights here for those who are on YouTube, you can see just how many notes I've taken on Ray Dalio's principles of the book.


Like I would, I almost highlighted the entire book, right? So there's no way I'm going to be able to summarise this in one podcast episode. I might pull out three of my favourite points from the book.


I'm currently writing sort of a post as well, like a tribute post to what I've learned from this. And I thought I would get it done in one sitting, because that's how I've written a lot of my things in the past is just get it down in one sitting.


But I'm realising it's going to take a lot more than that because it's so much to sort of I'm trying to conceptualise how I can make it in a digestible form for both the reader and myself because a lot of it is me trying to have a reference point so that I can refer back to in the future rather than reading the whole book.


So let's get into it. I'm going to do three of my favourite points from the entire book. Of course, there's so many more. I'll link the entire book down in the description so you can see it, whether you're listening on podcast platform or YouTube, so the book will be in the description.


Highly recommend reading it by the way. So number one, he's got a five step basic approach that he's followed since he was a 12 year old caddy, right? Which is when he got his first taste for investing in the stock market.


So number one, working for what I wanted, not for what others wanted me to. Number two, coming up with the best independent opinions I could master to move towards my goals.


Number three, stress testing my opinions by having the smartest people I could find challenge them so I could find out where I was wrong. Number four, being wary about overconfidence and good at not knowing.


And number five, wrestling with reality, experiencing the results of my decisions and reflecting on what I did to produce them so I could improve. Now, that that could summarise the entire book almost, or those those principles, those five steps are enough to sort of, I don't know, live a good life by in my opinion.


So it's number one, working for what I wanted and not what others wanted me to do. And by the way, this is this is my one first takeout. So this is five points that Ray's written, but it's my one takeout so far.


So working for what I wanted, not others wanting me to do. And that's, that's incredibly hard thing to do, like very, very hard and something I've been trying to do over the past year or so.


That's why I left my job at Apple sort of trying to do something that I wanted to do. I really loved it there. But I wanted to sort of move on and try try and do something that I want to do and not someone what someone else wanted me to do.


And I think that's, that's a recipe for success. Like, if you're doing something that you want to do, like there's not much you can you can do wrong. Like if you're getting up every day, and you're sort of doing doing the things you want to work on, like that's, that's a way to fulfilment, not only success, but fulfilment as well, right?


But very hard to do. The only way I think you can, and look, I'm only 23. So I don't know. I don't have the experience to sort of pass judgment on this sort of thing. But my intuition is telling me like, the only way you can find that is by trying a whole bunch of things.


Try a whole bunch of things, get good at something, keep improving on that, be surrounded by people who are also challenging you. And that's that's why you can work for what you want. That's, that's, that's the formula, I think, I don't know for sure. Test it yourself.


Actually, that's going to be number two of this book. So we'll get back to this, test it yourself.


Coming up with the best independent opinions I could master to move towards my goals. And that's it, right? So reading books is one thing, like learning from others is fundamental, of course, if you want to sort of accelerate your learning.


But then again, taking what they've, they've told you and what you've learned from others and what you've read in a book and what I've top said on a podcast and what you've watched on a YouTube video and things like that.


Fundamentally important to gaining knowledge at an accelerated rate. But I think it's, it's even more important to sort of take the best things from that and apply to yourself.


Like if someone's, you find someone's working 100 hour weeks, and that's what they're preaching. And you are, you're looking up to them, and you're sort of trying these 100 hour weeks, and you're not sort of, I don't know, getting anywhere.


Like, that's, and it's not for you. Well, maybe that's that's not a piece of advice you should follow. Take the other things that they say and do that. The 80-20 rule, right?


Number three, stress testing my opinions by having smartest people I could find challenge them, so I could find out where I was wrong. This is really important as well.


Sort of, you formulate your own opinions, and then check in with your smartest friends or even not that just put like, go out go online, find out see if someone can stress test your opinion.


Get someone to shoot holes in it, right? Like it's easy. It's easy, like if you're talking to family and you have an idea if you have a business plan, I've done this in the past, right?


I go to my family and talk about what, what do you think of this? And of course, they don't want to hurt you, right? They don't want to let you down. So they say, that's great. That's a great idea. But what will really sort of set you apart?


What will really accelerate your learning and stress test those opinions? Well, that's what you want people, other people to do is go to smart people and ask them, where can you see holes in this?


Where can I plug this up? Where can I sort of, I don't know, make this stone wall this, right? Make it solid. How can I make this solid? That's, I don't know, that's, that's something I need to work on personally is having my opinions stress tested by others.


I'm not good at that. I'm not good at that.


Number four, being wary about overconfidence and good at not knowing. So, no, where are you overconfident? Like I, I think that I'm overconfident in, I don't know, a whole abundance of areas. But it's also, and I can't pick any one example, but just, just let you know, I'm overconfident in some areas.


And it's good to be wary of this, like know where you're overconfident. So that sort of if you don't get sort of led astray by the fact that you're too confident and you end up down in the rabbit hole that you can't get back out of because you're overconfidence drew you there.


And good at not knowing. So, I think that's understanding what you're, what you don't know, right? Because as much as you know, it's, you don't know, like, exponentially more.


So there's, there's no way to know it all, right? So if you understand what you don't know, that's, that's, I think that's even more powerful than what you already do know.


So number five is wrestling with reality and experiencing the results of my decisions and reflecting on what I did to produce, what I did to produce them so that I can improve.


That's a reflection piece, right? Looking back on what you've done in the past and sort of how can you how can you do better next time? And I that's something I struggle with is because I'm always forward, right? I'm always blinkers on frozen yogurt machine, only output, right?


I don't sort of look back over what I've done, how can I improve? That's, that's something that I could have done, I could do better with this podcast, actually, looking back at past episodes and thinking about how I can improve.


Because at the moment, I sort of just make one episode a week and there's no structure and it's sort of, I don't know where I'm going wrong, I'm not going where I'm going good and things like that.


I haven't stress tested it with other people. But that's, that's, that's my number one, sort of pick out from the book is five, five steps to a basic approach that he sort of, he's putting into place since he was 12 years old.


And alright, let's go for number two. Why is a really good one? I said I was going to get back to to that. So number two will be I want you to work for yourself to come up with independent opinions to stress test them to be wary about being overconfident and to reflect on the consequences of your decisions and constantly improve.


So actually, that was more of a part of number one. But the first introductory few words to that sentence is number two, like truth, right? His most fundamental principle is truth. And what where does it come from that?


So he's written this book, but it's also in a humble approach, like the guy's worth $17 billion. And head of one of the biggest hedge funds in the world. He could write this book and say follow these steps, I know that I know the answer. But it's anything but it's saying, here's what's worked for me.


I want you if you want to take them, make sure you test them first and decide whether they're right from you. Right? His most value, his most fundamental principle is truth. So after every, every principle he writes down, it's prefaced with the fact that he wants you to ask, is this true?


Is this true for me? Right? So although, like there's so many so much wisdom in here, like the notes, my notes are just galore, like I pretty much highlighted the entire book. But the whole the whole thing comes back to the fundamental principle. Ask, is this true? Like decide what is true for you.


So this can be related to anything, anything. Someone gives you advice, is it true for you? Is it what you want to be saying yes to? Is it what you want to be saying no to? Is it something totally different? Right? What you've gone through high school, I've gone through high school is what they taught you true.


You go to university, I've gone to university is what they told you true. You're working in a job. Is that job true to what you want to live out? Right? And these are not simple questions to answer. It's not something you can sort of do in five minutes. And this is a note to self.


Daniel, like these, these questions, I'm talking to myself in the third person. We're these questions, sort of the hard questions that I've been avoiding them to write, like, is this true? Or what? What are your goals? Right? It's easy to avoid them because it's so so you can so quickly get entertained by something new, rather than sort of spending the time to sit and think and devise a plan out for yourself.


Or what is true because then also once you do that, you got a whole bunch of things you have to say no to saying no is hard. So that's my second pick out. Raise most fundamental principle is true. Ask yourself with everything. Is this true? Let's go one more before we wrap up the podcast.


And of course, there is a whole bunch more in the in the book, I highly recommend it and I'm going to I'm going to write a more more in depth blog post in the coming weeks. So be sure to check that out. That will be you'll find it you'll find it on my website and whatever.


We got number three here. This is part from part three, the management principles. So I believe to have a great company, you have to make two things great, the culture and the people. I totally agree. If you look at it, this is from my perspective. And I haven't I have never made a company full disclosure.


I've worked for a company worked for a few companies. And every time I've worked at great places, say for example, Apple loved it. Other places didn't like it. Why? Because Apple the culture and the people like that's that's literally what was although it's like the most valuable company in the world right and that that's not something you see every day.


Like I was just in the retail store, right? You don't see the billions of dollars in the iPhone has been made and whatnot, things like that. The experiences you have with other people like the I know the staff, the customers, everyone, right? That that is really what matters like the relationships that I formed from there will last a lifetime.


And that that is really sort of why I enjoy working there. I didn't really like these devices are great. I love them. Don't get me wrong. I love the entire ecosystem. But the culture and the people was was what I love the most and what I missed the most.


I don't miss typing up on an iPad every day. I miss seeing seeing my friends at work and seeing and seeing the customers and the smiles on their face. But that's okay. We've moved on from that. But I think that's not only just in with the company that's in with a great life is sort of the culture and the people I've spoken about this before in previous episodes, so where you be careful where you put your attention because you're the average of the five people you spend the most time with right?


And if you're surrounded by great culture and great people, well, that's, that's a sort of stepping stone to having a great life, right? That's what I've been trying to, trying to value a lot more in the past is rather than sort of material goods and whatever is experiences, people, culture like that's, that's, that's to me is is number one.


So that's the third point I pulled out. So I believe that to have a great company, you need to make two things great, the culture and the people. An example, let's look at General Motors versus Tesla. This is just in my opinion, if I think of a company that I'd like to work for Tesla, because just imagine the culture there, right? Everyone's trying to drive towards each other and make, make great things. And that might change over time, who knows?


And General Motors like it doesn't really appeal to me. Like what's the culture? Like, I don't know. But that also could be biased because I've read Elon Musk's book, who knows? But yeah, people and culture, not just in company, but in life, I think, are fundamentally important.


That's it. That's a wrap. That's episode 108. That is three things that I've taken away or three of my top things from Ray Dalio's principles, the book principles, I think it's life and work is the subtitle. I'll link in the description or not. And I'll write a blog post about it. I'm currently about 1000 words into it, which will probably get culled to about maybe 800 or so. And then I don't know what it will finish up at maybe 2000 words, who knows?


In a couple weeks, coming weeks, sorry. Be sure to check out all my socials and whatever you know where to find me at MrD Burke everywhere at MrDBurke. A lot of my writing goes on MrDBurke.com. You can also sign up to my monthly newsletter, which is a few cool things that I found around the internet that I think are worth your time. Trust me, it's a small little list and you'll get some value out of it. I send it out once a month. It's called a few cool things.


And otherwise, yeah. Hope you have an awesome day. Thank you so much for watching. Thank you so much for listening. And the challenge of today is write down a principle that you think that you've been living by or write down a principle that you'd like to live by. And look, these things can change but ideally they won't.


Biology and Physics meet Computer Science | Learning Intelligence 7

What's up y'all? Welcome to Learning Intelligence episode 7.


It's been an awesome day of learning today.


A bit more on the theory side today rather than sort of jumping in and doing practical stuff


and coding and whatnot.


I've still got to work on that Pac-Man lab that I was doing last, in last, last episode, episode 6.


That will be tomorrow's task.


Today I like, I don't know, Tuesday seems to be my most productive day,


so I like to reserve the hardest, the hardest things of the week for Tuesday.


And Monday is theory getting me, getting me warmed up for the rest of the week.


What have I been up to today?


Well, I just had some cereal, brain food snack.


Cereal's like a anytime of day food.


Read some more of this book.


I'm about, not even one chapter through, I'm still in the introduction.


I'm learning a good, good deal of history about where artificial intelligence actually came from.


Where the, where the first computers actually came from


and all the different fields artificial intelligence sort of takes from.


And it's, I think that's why it's so appealing to me.


I know I mentioned this, I think, in the last video.


But artificial intelligence literally takes from all the major fields.


Mathematics, psychology, philosophy, economics, computer engineering, both hardware and software.


You need the hardware to run the software.


Otherwise, after, after I did a little bit of reading, I went into the next class in Udacity.


And the three algorithms I learned about today, or three, three classes of algorithms I learned,


all borrowed from either a physical concept or a biological concept in the real world.


So number one, I'll try to remember more off the top of my head.


If not, bear with me, I just learned all these things.


Number one was simulated annealing.


Why am I showing you this diagram?


Well, this animation here exemplifies what simulated annealing does.


So if you imagine this red line starts off, it's moving around really randomly,


trying to find the maximum point of this graph, which is right here.


And it starts off extremely random and then finishes off.


Once it gets closer to the, to the maximum, the randomness slows down.


And it only jumps in small little gaps and then eventually it finds the top point.


So where does simulated annealing come from?


Well, you can imagine to anneal is to heat metal or glass and allow it to cool slowly.


Thus subsequently changing its form, moving towards a solution that you would prefer.


So with metal or iron, or in the case of a sword maker, which was the analogy that was


used in the lectures, a sword maker starts off with a hot sword, a hot piece of metal,


and starts beating it down.


And then allows it to cool and then repeatedly heats and cools until he gets the form of


the sword that he wants.


Not hard, well hard, but not brittle.


So the ideal solution.


That's what happens with simulated annealing.


The high temperature is the high amount of randomness, what you saw in the graph with


the bar was moving really fast.


And then the cooling was the randomness of the solution, of the little data point moving


slowly down until it gets to a cooled state and gets to the solution that you want in


the case that we saw was a pinnacle of the graph.


So at the start, high amount of randomness, bar moving across the screen really fast.


And at the end, slow amount of randomness, bar moving slowly and converging on the solution.


The second algorithm I learned about was the hill climbing algorithm.


So if you imagine again you wanted to get to the top of this point here, but you could


only move left and right.


So you might get stuck at this local optima here, or you might get stuck at even this


tabletop over here.


So what the hill climbing algorithm does is finds the optimal height after stepping left


and right.


But a third one was probably my favorite, was the genetic algorithm.


So the genetic algorithm models biology.


It uses evolution to find the optimal solution for your problem.


That rhymed, evolution to find your solution.


I could be a, nah I'm kidding.


So with the genetic algorithm, it starts with a whole bunch of solutions.


Let's imagine them as parents.


And then it combines them by using genetic algorithm crossover.


So much like if two parents in real life, you have a mother and a father were to have


a child, the child you would expect to get a crossover of genes, half from the mother,


half from the father.


And it uses this crossover effect to continually go down through generations until it finds


an optimal solution.


But there's a problem here.


What if the solution didn't lie within the parents?


What if the parents weren't possible, like the combination of any two parents was never


possible no matter how many generations you had to find the right solution in the children.


And that's where genetic algorithm mutations come in.


When the two parents combine through genetic algorithm crossover, there's a small chance


with genetic algorithm mutation that one of the data points in the children will randomly


change to something else within a certain range.


And those random mutations allow for enough diversity in the gene pool, if you may, so


that eventually after a certain number of generations, an ideal solution will come about.


I've just been teaching Pac-Man how to play.


Go buddy.


You can get it.


Get to the goal.


Get there.


And...


He's done it!


Winner!


Check it out.


Record win.


So I made some progress in the Pac-Man lab and the Udacity search class.


That algorithm took me a while to implement.


I dedicated a solid hour and a half of uninterrupted time just to turn this little piece of suede


code.


Is that how you say it?


Suede code?


I'm not sure.


Suede code here.


The uniform cost search function on a graph.


So that's something I need to work on is turning suede code into...


I still...


That word...


I never really said that word out loud.


I've heard it, but I haven't really said it.


Suedo.


Persuade.


It's a fun word.


I like it.


How many times can I get it in this video?


But that's something I need to work on is implementing suede code into an actual algorithm.


So I can understand sort of or mostly what the code is saying in the textbook when it's


in plain English, but something I need to work on is going into making it into an actual