Deep Learning for Computer Vision with Python and TensorFlow – Complete Course
Key Takeaways
Explains deep learning for computer vision using Python and TensorFlow, covering the basics of computer vision and implementation of algorithms
Full Transcript
welcome to this course on deep learning for computer vision with tensorflow in this course you'll Master deep learning Concepts and their applications in computer vision tasks such as image classification object detection and image generation you'll learn about tensors variables and neural networks including convolutional neural networks through practical projects like predicting car prices and diagnosing malaria you'll also learn Advanced Techniques for model performance data augmentation and deployment as well as learn about modern convolutional neural networks transfer learning and Transformers Envision this course comes from neural learn which offers a variety of machine learning courses hi everyone and welcome to this course on deep learning for computer vision by noahlearn.ei in this course we shall make use of tools like hog and face tensorflow Onyx and 1db to build and deploy AI are different computer vision Solutions applications of computer vision are everywhere today going from Tesla self-driving cars to livestock farmers who can now automatically count the number of animals they have to mobile facial recognition apps and even in the hospitals where the gastroenterologists could make use of computer vision for much faster Diagnostics behind those different computer vision Solutions is deep learning models like the convolutional neural networks and the vision Transformer throughout those course we shall explain in detail how The Confident or the vision Transformers work given that these are all deep learning based models let's look at the high level how deep Learning Works let's suppose we want to build a system where we get an input like this one and we are able to say that this is a damaged car or get an input like this one and we say that this car is still intact then in that case we could build and train a deep learning model which takes in this image for example and then for its output here we'll be able to see that this car is damaged or in the case where this model takes in this other image then we'll be able to set up this car is intact nonetheless for this our deep learning model to be intelligent enough to make this kind of decisions we need to train it and the way this training is carried out is we have thousands hundreds of thousands or even millions of damaged cars like this and so our output level is obviously damaged on the other hand we have thousands of cars which are still intact and the output level is intact and so now we have what we'll call a data set that is those inputs and the corresponding levels and then in this uh deep learning model right here we stack several neural network layers so we'll have this we have some other layer some other layer right up to the output now it should be noted that this neural network layers here are essentially mathematical functions if you do not have a background in mathematics you shouldn't be worried as in this course we shall focus on implementing all this practically so that said as we're saying this we have here all these layers this neural network layers we have here are essentially mathematical functions and if we have a linear layer then this means that we could take an input X multiply this by a weight which we'll call W and then add some bias which we'll call B and then this gives us the output which is that output of a given layer so here for example let's suppose this input is X we have X here we'll take X multiplied by the weight and then add up the bias to have the output at this level y let's call this X1 then this is y1 and then this y1 will be used as inputs to this next layer and then we'll have Y2 right up to say y n and so during the training process given that we know the input and the output our aim will be to obtain the values of this W and this B which in short end when we pass in images like this or this the model is able to know whether it's a damaged or an intact car now we see that at every layer we have our weights and biases which are all going to be updated during the training process making use obviously of our training data that is this inputs and your corresponding levels such that when shown an image which this model has never seen or deep learning model is able to take the right position so in essence this kinds of models are called The Learning models because we have several layers stacked between the inputs and outputs and the number of layers we stack represent the depth of our model on the other hand deep learning algorithms fall under a category of artificial intelligence algorithms known as machine learning where the model learns from the training data a prerequisite to this course is knowledge of Python Programming so you could head over to the neural learning YouTube channel and check check out our free essential Python Programming playlist which should help you master the basics of Python Programming let's now take a look at what we'll be learning in this course the way we've designed this course is such that will start from the very Basics so we'll suppose that you have no prior experience in deep learning and so we'll start with basic topics and tensorflow like the tensors and the variables and from here we'll dive into solving our first practical problem which is that of car price prediction now it should be noted that although this isn't necessarily a computer vision problem this will permit us learn how to prepare our dealer with tensorflow build simple models like the linear regression model train these models evaluate them and test out this model such that by the time we move into our next project which happens to be now a computer vision based project which is that of malaria diagnosis we already have what it takes to start building more complex models like the convolutional neural network but before building them we'll first of all understand how and why they work by the end of the section we should have learned how to build a simple solution for our malaria diagnosis problem and so now we're ready to dive into building more advanced models with tensorflow after looking at this more advanced models we'll then dive into evaluating classification models so we'll look at different metrics like the Precision recall accuracy and then we'll learn how to come up up with the confusion Matrix and the ROC plots once we're done with this we'll dive into model performance here we shall look at tensorflow callbacks learning rate schedulers model checkpointing and then how to solve the problems of overfeeding and under feeding that said one main way in which we could mitigate the problem of overfeeding is by using the documentation and so we have the section reserved for the augmentation using tensorflow and augmentations now once we're done with data augmentation we'll look at more advanced concepts in tensorflow like custom losses and metrics the eager and graph modes then custom Training Loops so learn how to train our model without necessarily using the fit method we'll look at tensor word integration where we'll learn how to carry out data login reviewing model graphs hyper parameter tuning then profiling and visualizations from here we'll get into machine learning operations with weights and biases where we shall look at how to carry out experiment tracking hyper parameter tuning data set and model versioning with 1db and now we shall move to our next project which is that of human emotions detection um again here we shall prepared data set build our model carry out data augmentation and then we shall look at tensorflow records now once we're done with the section we shall go ahead to look at modern convolutional neural networks like the Alex Nets vgg Nets resnets mobile Nets and the efficient net with all this in place we'll learn about transfer learning we should help us now train our models much more efficiently using already pre-trained convolutional neural networks then we'll look at how the convolutional neural networks take Decisions by visualizing intermediate layers and so up to this point so far we've been looking at the convolutional neural networks and now we'll be set to dive into the vision Transformers would understand how to work and even get to fine-tune our own Vision Transformer using the hog and face Transformers Library and so now that we have a working solution the next logical step will be to deploy this such that anyone around the world could make use of a model which we've just built and so we'll convert our trained model to the Onyx format would quantize this build out a simple API and then go ahead to deploy this API to the cloud now that we've learned how to deploy our computer vision models to the cloud we could dive into other computer vision problems like object detection and in this section we'll look at the basics of object detection and also build and train our own object detection YOLO model from scratch with tensorflow then finally we'll dive into the domain of image generation where we'll look at the variational auto encoders and the generative adversarial neural networks which we shall use for digit generation and phase generation in this course the coding platform will use to build and train our models will be Google collab we shall make use of Google's free gpus to train our models we've just explained that in order to train a model like this one we make use of a training data set which has its inputs and its corresponding outputs those inputs and outputs are multi-dimensional arrays which are commonly known as tensors in the section we shall start with tensor Basics then we'll move on to Casting and tensorflow we'll look at initialization indexing Broadcasting algebraic operations Matrix operations commonly used functions in machine learning would look at the different types of tensors like the react tenses sparse tensors and even the string tensors in the context of deep learning tensors can be defined as multi-dimensional arrays an array itself is an ordered arrangement of numbers it's important we take note of these keywords as the data we shall be dealing with like for example this image right here can be represented using this numbers which have been arranged clearly in an ordered Manner and can be represented in multiple dimensions in the specific case we have this array which is represented in one two Dimensions So This Is A 2 Z or two dimensional array or what we generally call a matrix now we'll explore different types of arrays based on the dimensionality so here for example we have what we'll call a Zero Dimensional array which is simply because this array or this tensor contains a single element so let's say we have 21 this is a Zero Dimensional array let's say we will have one this is Zero Dimensional so on and so forth so essentially once we have a single element then it's a zero D um array and then now for our next example we have this 1D cancer right here which in fact is a combination of several Zero D tensors so if you look at this you see that this is a zero detention this is another zero detensor this is another zero detensor so this Vector is made of three of these kinds of elements now you could have other examples like this let's say we have five um eight and then three oh let's let's change the length so let's say we have one of length five for example we could have 10 2 11 4 and 7. so this is a 1D tensor we have right here so so far we've looked at the zero detenter we've looked at the 1D tensor and now we could dive into the 2D tensor which essentially is made of a combination of several 1D tensors you could see that right here this is a 1D tensor here this is another one detensor this is another 1D tensor and finally here we have a 1D tensor so when you bring together this one the tensors you form this 2D tensor for a three-dimensional tensor you might have guessed this right you would simply combine several two dimensional tensors so right here we have this 2D tensor with this other 2D with this other 2D and this other 2D forming uh to v d tensor we could visualize this differently here so we take this this this and this now you see we have one two and um the third dimension now that we understand this we're gonna take a look at the concept of tensorships starting with this given that it's Zero Dimensional then there is no shape with this one here it's one dimensional and it's made of three elements and so we could see this is of ship three so we have three and that's it now for this other one it's made of one two three and four One D tensors and each and every one of this is made of three elements so this year for example this made of three elements this made of three this three this three and given that there are four of this made of three elements its shape is four by three so that's it that's how we obtain the shape for this now for the 3D tensor we have here is made of one two three four two D tensors so this here we have four two uh two detenters and each and every one of this is made of two 1D tensors where each and every one is made of three elements so what we'll see here is this is two by three this year because we have one two is two by three this is two by three and this year is two by three and now given that we have four of these different two by three um two detenters then we would see the shape of this 3D tensor is four by two by three so similar to this we have four by three this is four by two by three now notice that the number of elements we have here tells us or gives us information about out the number of Dimensions our tensor is so here because we have a 1D tensor or one dimensional tensor we have just one here because it's 2D or two dimensional we have two and here because it's 3D we have three also in Matrix notation we would say that this year or this Matrix right here is made of one two three and four rows so number of rows we have here is four and then here we have one two three columns number of columns is three in the case of this 3D tensor we have right here we have one two rows and one two three columns for each and every one of this to the tensor we have right here now we have some basic knowledge on tensors let's go ahead and create them with tensorflow so first things first would import tensorflow as TF and then you should note that because we're using collab we do not need to install tensorflow before making use of it all we need to do here is just import and we're good to go now first thing we're gonna do is we're gonna have our tensor which we'll call tensor 0d and the way we're gonna create this tensor is by calling on the constant method so we have tensorflows constant method and then we specify for example that we want this to be let's say four so that's it that's how we um create a Zero Dimensional tensor you could see here from the documentation that this constant method takes in a value takes in a data type takes in a ship and um a name but for now we pass in only this value right here and then we could go ahead and print this so let's have denser um Zero D run that you could see right here we've had the sensor which has value 4 it has no shape And it's of type int32 with this we could go ahead and um build out our tensor 1D tensor 1D we have as usual our constant method but this time around because it's 1D we're gonna have a list we're going to take this list we had here two zero negative three and then putting this now right here we have two zero and negative three now let's print this out we have tensor 1D and there we go you see we have the value which is this 1D orders list we could see shape right here and then the data type now let's modify this and say we have eight and less than 90. let's run this now and check out as chip you see here this is our new list all this on your tensor and then you see now it's five because we have five elements in here but again this is still an integer so let's add this here changes to a float and then see what we have see here now this is a float so it's still um our inputs by the time around floats um same shape but the data type changes from int to float let's get back to integer and then we move now to the 2D tensor so we've looked at 0d 1D to create a 2d tensor it's going to be quite as simple as we've done with the Zero D and One D so yeah we have two D and then we have that's usual uh constant and then um let's open up this square brackets so we have the square brackets right here opened up and then we'll have this 2D tensor we have seen already so let's have this right here we have one two zero we put a comma to move to the next row or to the next line we have three five minus one then we have one five six and then we have two three eight okay so as you could see here we have this 1D tensors which we stuck and which will form our 2D tensor now as usual we have a constant metal which takes in this value and you should also take note of the fact that we have this outside of this stacked 1D tensors now we have this let's go ahead and print out tensor to D we have to answer to D and there we go as you could see we have our 2D tensor that's it we have the shape four by three which is what's expected and then the data type is in 32. from here we move on to the 3D tensor which is essentially made of this 2D tensors which have been stacked together so let's go ahead and see how to create this with tensorflow we'll start by putting together those two detenters we had one two zero three five minus one so that's it three five minus one and then we have all those remaining 2D um tensors so let's get here we have tensor three tensor three D as a constant we have our square bracket here and then we simply copy this copy this and then paste this in here now let's um print this out and see what we get so here we have denser three d as you can see we're getting an error and this comes from the fact that we omitted commas now if you look at this you'll see that uh between 1 1D and another 1D to form this 2D there is a comma and so this means that between this 2D and this other 2D there should be a comma so let's have this comma here let's have this comma let's have this comma and this comma okay so let's run that again and see what we get as you could see we have this our 3D output of shape four by two by three and that's exactly what we expect to get did it type in 32. now before we move on we could we should note that we could also do let's let's have this here we could also do um tensor 3D shape to obtain this um tensorship so you see that we have that um right there we could replace this zero you could have one see that's zero that's one that's two um there we go let's let's have one that's one um that's it okay and also we could also have here let's say three we could do ending and this gives us a value of three showing us that our tensor is a 3D tensor at this point with look at uh Zero D One D two D and even the 3D tensor let's go ahead and check out a 4D tensor but the Constructor for the tensor would need several 3D tensors so let's have this here we have this 3D well we saw this already this is this 3D and then we move to this other one right here or these two others we we have this other 3D and this other 3D and then now if we stack this three 3DS up what would obtain will be a 4D tensor see we have this one we add this other and we have this other so now we have here of four dimensional tensor which is made of three three-dimensional tensors now you should know that this could be two this could be four this could be whatever number so if we consider only this two then we're talking about two three dimensional tensors but uh what's so important to note here is the fact that once you stack several 3D tensors you create a 4D tensor now at this point you could take it as an exercise to create your own for the tensor so you could pause the video but um we're gonna go ahead and show you how to create this person's first we're going to take up our 3D year we have this 3D tensor let's just copy this there we go we paste this out here let's repeat that operation copy and paste again but now let's modify some values so let's say we have 13 26 let's just randomly modify this um 23 so it's now this these are the 3D is different from the other one say 30. okay now let's copy this again and then paste out here so we have the three three detensors um let's say this is one oh let's just add zeros we have here um 23 um two four and C2 okay so now we have our three 3D tensors we have this one we have this other one and then we have this other one now to create our for the tensor as usual we call on our constant method so we have 4D um we have the constant and as usual we have all square brackets which will open up and then now we just simply take this and copy all this to the end cut this from here and then paste this all year okay so we see we have three of this um 3D tensors now remember last time when you were separating two 3D tensors or between the three detenters we need to have a comma so here we're gonna have this comma and then here we're gonna have this camera and here we have comma okay so that's it so let's run this or let's print this out and then see what we get so here we have print um tensor for the there we go you could see from here we have our 4D tensor you see it's cheap three by four by two by three and this is because uh for the tensor is made of one stick this off it's made of one two three three detenters so that's why we have three and then uh for each and every one of this we have four that's one two three four two detenters so here we have four and for every 2D tensor we have one two that's two rows and one two three that's three columns and that's now exactly what we have here so we still have the same data type we have our values which you could have here and that's it if we get back here we'll see that we have different data types which we could use so instead of uh does this default int uh we could have um TF float say 32 and you'll notice that the outputs as we have seen already should have this decimals since we're now dealing with floats now the float we have in here is of type um float32 or specifically the flow 32 meaning that the Precision value here is 32. now if you reduce this if you reduce this you'll see that you would actually have the same output but the difference is that less memories are located for storing this tensor as compared to maybe even let's say the 64 that's float 64. and so in set in contexts where we have the memory constraint we would want to use the lower precision tensors in the documentation you could have um all the different deleted types um which are supported in tensorflow so here we have quantized data types and talking about quantization we're going to treat this in subsequent sections and so don't bother for now if you don't really Master this um here we have the brain floating points here we have the Boolean here we have complex and it's 128 and 64-bit versions here we have the double which in fact means the double Precision floating point now this is double because the flow 32 is a single Precision so here we have single the floor 16 is half prediction or precision and then the double is uh double precision here we have the ins and the different versions or the different uh precisions or we have the quantized ins um we have resource we have string we have unsigned int and then we have variant getting back to the code if for example here we have this float let's just add the decimal so we suppose that this is a float and then now we do ins let's see in 64 we run that you'll see that I would obtain an error so let's have this here what do we see we told that we cannot convert this um tensor to or to eager tensor of the data type in 64. but now if we use the cast method if we do tensorflow cast um and then your order let's take this back let's let's have our tensorflow or our tensor 1D and then let's take this off or let's yeah let's just have this float um 64. there we go or let's say flow 32 and then let's say we Define some casted tensor cast the tensor 1D and then discuss the tensor 1D is simply going to be the casted version of this or one detensor so here we have tensor 1D and then we specify the data type and now we say we want this to be in 16 for example so yeah we're going to print out the tensor 1D I also going to print out the cast that tensor 1D we get in this error we should have had t f dot so let's have this year there we go and then let's look at what we have as output as you can see thanks to the casting operation we are able to get from this float to this integer tensor and so this tells us that instead of um coming right here and saying for example in 16 or let's say in 32 it's preferable to make use of the cast method that said let's say for example instead of having this that's instead of um casting this into an integer we want to cast this into a Boolean so let's run this you see here that we get all um true except for this one year which is false and that's simply because this is a zero so it looks like the water casting method does is for all the values which are different from zero they're true but values equal zero equal false we could also go ahead and create our own Boolean so let's say we have tensor tensor bull let's call this tensor Bull and then we have uh this list made of this tensor so we could have true true false true true false okay so let's print out tensor bowl and see what we get as you could see here we have our output tensor of shift 3 and here is values you see the data type bull right here now another data type which you could look at is um the string so let's let's say we want to have tensor string um there we go let's say we want to have um Halo World hello world um let's print this out tensor string there we go we have our tensor we could also put this in the list because right now this is a Zero Dimensional tensor so let's put this in the list and uh uh hello world hi and we'll close that and now we have this 1D tensor of shape 2 which is a string from here we would also look at how to create or how to convert a numpy array into a tensor so let's call this um NP array first of all we'll start by importing numpy as NP we could just do that right here import numpy SNP there we go and then we have um NP array and let's say we have NP array and then let's take in this here let's say one two three or one two four there we go print this out we have NP array right here now we could make use of this tensorflow convert the tensor method so let's say we have here converted converted tensor and we have um convert to tensor which essentially takes in a numpy array now let's have this and then print out the converted um tensor with that getting back to the documentation we will look at a couple of other methods like the I method here we have this I method right here as usual we have the well described method in the documentation which comes with this short phrase explaining how it works it comes with this different arguments and also even some examples so getting back here we told that this I method permits as construct and identity metrics or batch of matrices so now we have this definition we could simply copy this out and then yeah back to the call right here pieces out and let's say we call this um I tensor I tensor and for now we have this number of columns which is known the bad shape known the type flow 32 name known now let's say we want to have three rows so we have number of rows which is equal three now in this case I'll print this out so we see the kind of output we get here we have I tensor and there we go as you could see we have this identity Matrix where all the values of the Matrix are zero except for those of the leading diagonal let's um show clearly this leading diagonal right here here we have our Matrix which is this and then we have this element of the leading diagonal which is equal one now you should note that you could you could say for example um let's say three times this and you should have all the elements of the religion diagonal to be equal three and the order is zero so in this case we now have someone like this so you see all these three while the rest zero now let's get back let's take this off here we have our eye tensor and then we see that we could specify the number of columns now here uh or previously where this was set to known we had a square Matrix that is when you define the number of rows to be three the number of columns automatically takes up the value of three so we have a three by three Matrix and obviously the type here is flow 32 could modify this and say for example 16 from that let's try out bull after this there we go we have float 16 let's try out board you see everywhere is false false false false false false except for the listen diagonal which has true now getting back let's say here we have five and then now number of columns let's say this to three you see right here the output we get now it's it acts like we have um a five by five metrics so we suppose we had a five by five Matrix where this would be zero zero this would have been zero zero this would have been zero zero this would have been one if this was five by five zero and then your zero one so this is what we would have had if we did not uh if we let this to to be known that is uh number of rows equal number of columns but now that we've set number of columns to be three this part has been cut off and so this is what we're left with now with that said let's go ahead and take this back to Norm and then let's set a bad shape so let's say this is three I'll run that as you could see because we set this bar shape to B3 um here we have this output which is three by five by five well let's let's change this to two so you could see that this actually um is responsible for deciding on what number of batches we have right here so here we have two by five by five so essentially saying that you want to have this by shape to be two like this means you want two five by five matrices which are identity matrices and that is uh which have their values all zeros except for those of the religion diagonal which are equal one and so we see how we could create this 3D Matrix or the 3D tensor from um the I method now we could go ahead and say for example one foyer let's run this um and see what we get we should get two by four two by four by five by five so here we have two by four by five by five and that's it for the eye method we move on to the next method the fuel method here we have a method as defined during the documentation which creates a tensor filled with a scalar value so here we have this fuel method which we're going to copy but uh before testing out the code you could see here from the example that with this field method we have this tensor which takes or which has shaped two by three and which has value 9 on all different positions so let's get back here pieces out let's call this fill tensor and let's say this Dimensions let's say we have three by four and unless they want to have the value um let's say five okay so let's print this out and see what we get fill the tensor and there we go that's the output we get now let's have this one for example to run that see we're able to create this 3D tensor where all the values or all the elements in each position takes the value 5. from here we'll go on to the ones method and should be noted that this once method is quite similar to The Fill method in the sense that this creates a tensor just like with a few method but the only difference is that your all the elements are set to one so you notice that you're in this definition uh we do not have this value argument right here we had a value which we passed but with the ones there is no value because the value by default is one so let's have this here and then it's all right here see we have this once so we'll call this once tensor um there we go we specify the shape let's say five by three and then we print that out so here we have one stencil and there we go we have this output Matrix which um is made of five rows one two three four five and three columns one two three where all the elements of this tensor take up the value one now you could obviously do this to have or to obtain a 3D tensor so that's the output we get you see it's five by three by two from here we'll look at the ones like and what this one does is it creates a tensor of all ones that has the same shape as the input so what this means is if you have an input like this one let's say we have um 12. let's not make that one 12 1 3 and then five um seven two this actually a two by three Matrix let's change this so you see that this is two so we have the shape the shape is um two by three so it's ship is two by three now if this is an input here if this is the input into our ones like method what will get us output will be um a matrix or tensor with this same shape that is we ship two by three so our output is going to be having a ship two by three meaning that we're gonna have um two rows and then one two three columns but the output or rather the values we're going to insert here will be all ones so now we're gonna have one hence the name once like so uh this like is actually for the shape of this so you imitating the input with respect to its shape now getting back here you see we had this field tensor which is a one by three by four tensor so let's um let's have this right here let's say we want to have uh ones like tensor there we go TF once like and then we have fill tensor fill tensor there we go okay so let's print out this once like tensor now before printing let's um try to obtain the output so here we know that this is field tensor the shape is one by three by four so it means that we should have an output of shape one by three by four where all these values are once so let's run that and make sure that that's the output we have there we go this is one by three by four and we have all ones from here we move to the zeros method so it's quite similar to the ones here uh just like with the ones we have um all elements set to a given value with the ones all the elements were set to one with the zeros all elements are set to zero so that's essentially it now let's just modify the code a little right here so this was once tensor um let's change the shape this three by two and then instead of once here let's say zeros here we have zeros and um let's call this well let's see this is well let's just copy this out and put out separately so here we have this we paste that out here we have zeros and here we have zeros fine and here we have zeros okay so let's run that and there we go we should have this year so you see it's three by two three rows two columns that's fine and all values are zeros if you were once then you have all values once and for the ones or the zeros like is similar to the ones like so you could take that as a simple exercise we then move forward we have this shape method right here where we told that this returns a tensor signal of that it returns a tensor containing the shape of the input tensor so um as we had seen before we could obtain the shape of a tensor by simply um making use of that tensor's name dot shape now if we want to have an output like in our case now we want to have this output um tensor which contains the shape of our tensor then we could make use of this shape method from tensorflow so you see here we have the same four by two by three but this is now in this list um and then we have its shape and we also have its data type obviously it's made of integer so we shouldn't expect to have a float data type right here another method which we could make use of is a rank method which simply Returns the rank of a tensor so it takes an input and then returns its rank you have a simple example right here where we have this 3D tensor T and then when you call on the rank method you see that we obtain the output which is three so let's um put that out here let's just paste it out here and test that quickly there we go as you could see because the output um is a Zero Dimensional tensor the ship it actually has no ship but you could see its value right here that's three now if you take out this and take out this and then take out this other part here there we go we run this again we should have a rank of two this time around that's fine it's here rank is two we now move to the size here the size method which Returns the size of a tensor so you put in an input um in the size method and it gives you the size of the tensor we have as usual in the example here which we could copy but before running that we could read this um node here where we told this returns a 0d tensor representing the number of elements in the input of type output type this is the output type here which by default is into 32 so let's get back here and pieces out and check out the size as you can see here we have the size of 12 and that's because we have 12 different um positions or 12 different elements in our tensor now let's take this off again take this off um take this off there we go let's run that we should have six so that's it you see we have six and uh yeah we could also specify this the type um let's say float um 32. we're getting an error here uh got an unexpected keyword argument D type now getting back here you see this is actually out type not D type so let's get back here and then we have um out type so we have out type there we go run that and as you could see right now we have a float instead of an INT The Next Step we'll take is creating our own random tensors and that is essentially creating tensors which take up random values now in the case of tensorflow random normal our output values are going to be from or are going to be drawn from a normal distribution now we are going to explain at least at a high level what this really means for now let's just copy this out and get back to the code and run this and see what we get so right here let's say we have random tensor there we go we need to specify the shape so we'll say let's take let's make um a matrix or 2D tensor so let's just three by two now you see we have this mean value standard deviation values which have been given right year by default and we're gonna look um at what this actually means shortly the data type is flow 32 CDC is no name noon now let's run this or let's print this out and see what we get so here we have random tensor and there we go as you can see we have the set of values which are all negatives and if you notice they are very close to zero so here we have our particularly negative one about negative two is negative 0.3 very small number and negative of 0.5 negative 0.87 so these are numbers very close to seven let's run this again so you see that we're able to randomly or generate a matrix with this shape with random values you see that it takes up different numbers it's time around we have a mixture of positive and negative numbers but again these numbers are um very close to zero now what if we modify this mean so we modify this mean we'll run this again let's see what we obtain you see that we have these numbers now which are instead close to a hundred and so what this tells us is that we could make use of this mean and the standard deviation to decide on the kinds of random values we want to have here now to better understand what is going on let's consider this figure from this probability playground by Adam curningham from the University of Buffalo as you have noticed in the code when we did tensorflow random normal and the mean when we specify the mean yeah the mean is this mu you have your when we specify the mean to be equal zero most of the values we had were surrounding zero and when we set this mean to a hundred when we set it to 100 most of the values were surrounding a hundred now this curve you have here actually explains why so you have this curve right here uh which is bell shaped and the idea here is that it permits us randomly pick values around the mean that's around zero so that's why you notice that at zero we have the highest probability score here are probably the score is f of x so um for values around or values surrounding zero that this value surrounding zero there is much higher probability or chance of them being picked as compared to values far away from zero so let's pick out these two values let's say we have um let's say we want to pick out the two values 0.5 let's say 0.5 and we want to pick out negative five you would see from here that the probability of of us have a negative five is particle is zero that's almost zero but the probability of us having 0.5 as you could see from year after taking this middle the probability was having 0.5 is about 0.35 now if we change this value and take a hundred as we didn't with the code let's take a hundred we have that um 100 well it looks like they've fixed this to six so you cannot go above this you could play around this like this you go from negative six to six okay let's say the mean is six so we have a mean of six one thing you can notice is that now this um 0.5 as you could see 0.5 let's take this off um 0.5 no longer has a probability of about 0.35 of being picked 0.5 has a probability enough about zero have been picked while negative five also still has a probability of about zero being picked but um on the other hand as you could see here let's take this off you see that value is like five have much higher probability have been picked seven eight six did not have a much higher probabilities have been picked now it just means that if this was a hundred or if we're able to get to 100 then uh we'll be values like 97 or 98 99 100 101 102 and this explains why when we run this code with this mean we had values surrounding a hundred and that's simply because those values around the mean of um higher probabilities of being picked now let's take this back to zero and then talk about the standard deviation so we have the zero oh there we go you see get back to zero and now let's talk about the standard deviation but before um getting into any um explanations let's modify this let's say we take 10 years okay it looks like the max is fixed at 2.5 okay so let's let's say we have that 2.5 one thing you could notice is we still have this uh mean at zero we still have our mean at zero that's it makes sense because we haven't changed this but our Bell curved um ship now appears wider so an increase in Sigma Sigma here is what we call the standard deviation so it's what we uh called STD Dev in the code so we had the mean and the standard deviation so Sigma standard deviation the sigma square is the variance so Sigma square is the variance anyway uh what we're trying to see here is an increase in Sigma will make this curve wider and a decrease let's decrease Sigma you see decrease in Sigma makes the curve thinner and narrower now what this implies is that if we have let's say let's get back to this if we have Sigma Square as 2.5 there are much higher chances now that we could um randomly select negative five as compared to before so if this is negative five here you see there's a slightly higher probability of negative 5 and picked as compared to when we reduce this you see when we reduce this um you see negative five years practically zero but when we increase C negative 5 is at least this time around having some negligible value and so this is essentially the row that the standard deviation plays now if we reduce this again we find that even 0.5 because this is 0.5 around here even 0.5 let's take this off even 0.5 which used to have a property of about 0.035 of occurring um now has almost no chance of being picked let's increase it back and set it back to zero okay and so that's it at this point we could modify this we could take this to six and then take this to 2.5 and you see that we could take values now between 0 t go from zero to about um 11. with that said we'll then look at the uniform distribution or how to generate random numbers or random values drawn from a uniform distribution so again we'll just copy this out and then get back to the code we'll paste this year there we go we have the shape let's pick um this uh one okay and then minimum value zero and now we have maximum value so you see that unlike here where we had the minimum the the mean and the standard deviation now we have instead of a minimum value and a maximum value so let's let's let's leave the leave it at this and then let's say we have random tensor random tensor okay so let's print this out let's print out our random tensor there we go we have random tensor let's increase this so we have many more values five run that okay you see we have this values now let's let's say we change this max value and say it's um 880 or let's say eight okay let's say eight let's run that and what you notice now is you have much larger values well values between 0 and 8. but um before the values we're getting where values ranging between zero and one now this tells us that most probably this maximum value by default is one so here uh you see it's defaults to one you could always or make use of the documentation whenever you're in doubt so let's get back here you see we'll take this to 100 and then see what we get you see we have this values now between zero and one hundred now the question you may be asking yourself is what then is the difference uh between this uniform and this normal distribution so let's get back again here um in our probability playground and then let's pick out um uniform so there as you can see here many other properties distributions but we're going to focus on the normal distribution and the uniform distribution so we get into the uniform distribution and here's what we get so we have a and b now this is like our mean vowel which we saw in the code and this is like our Max vowel so when we say mean vowel negative one Maxwell one obviously our values will fall in this range Now by default this is zero and this is one on tensorflow so um that's why you saw the values ranging between zero and one now as the term goes it's actually uniform so this means that all this um values here have equal chances or probabilities of being picked and so unlike the normal distribution where we would have something like this something like this now we have this square instead or this um rectangle and so simply here all we're doing is picking the range of values which we want to have or which we want to be outputted so we could get year increase this um well you cannot you cannot uh the mean cannot pass the cannot be greater than the max so that makes sense let's reduce this reduce that see from negative four to four see we take all the values well that's it you see there we go Google from negative one two two that's it now one great thing is also the fact that we could modify this and have ins so let's run this and see what we get you see we have only integers now now let's say we had Norm let's run that you see we have an error most specified Max vowel in the case where the data type is integer so this actually um reading out here in the documentation so you can see here now that you need to have this Max file so let's change that to let's say 1000 so you will get values ranging between 0 and 1000 so we have five values here from the shape we could change this let's say five by five and then all those values range between um zero and one thousand another argument which we haven't spoken of so far is this seed argument and here we're told that this seed argument when used in combination with tensorflow random set seed will be able to create a reproducible sequence of tensors across multiple calls and so in cases where we want to produce reproducible experiments will want to set this Global seed value and also the seed argument value in this uniform or let's say normal function so let's go ahead and copy this out we get back to the code there we go let's just run this right here let's take off some parts and print this out so we print this out then we modify the shape and the max values so we have exactly the same value for the seed year which is 10 and then Here We Set This Global C to five let's run this see it outputs four three one four three two one one one and one three three now let's create another cell um let's copy this there we go places out here and you see we have the same Global seat um and then we have the seat of 10. now let's run this again and as you could see we have exactly the same output as this one see four three one four three one four three two four three two one one one one one one one and one three three now obviously modifying this and taking for example one gives us something different if you take 10 again you see you should have exact same output now you also see that here when we take this off if we take this off and we run the cell you see we have different outputs but when we get back here let's let's run this again see we have another set of different outputs but when we take this run that you see we have exact same output we had already and now if you want to have more details about certain seats you could always check out this um the documentation now we're gonna move on to tensor indexing so let's take this example we have this tensor to be indexed and we declare this we have the C of the constant and this 1D tensor in this out this is what we get now suppose we want to get this first four elements to get this for four elements we need to consider this or the indexes so here we have the zeroth index then here we have the first index yeah the second you have the third and the fourth so we want the first four elements all we need to do is take out those first four elements by doing this so we have indexed and then we have the square brackets we start with a
Original Description
Learn the basics of computer vision with deep learning and how to implement the algorithms using Tensorflow.
Author: Folefac Martins from Neuralearn.ai
More Courses: www.neuralearn.ai
Link to Code: https://colab.research.google.com/drive/18u1KDx-9683iZNPxSDZ6dOv9319ZuEC_
YouTube Channel: https://www.youtube.com/@neuralearn
❤️ Try interactive Python courses we love, right in your browser: https://scrimba.com/freeCodeCamp-Python (Made possible by a grant from our friends at Scrimba)
⭐️ Contents ⭐️
Introduction
⌨️ (0:00:00) Welcome
⌨️ (0:05:54) Prerequisite
⌨️ (0:06:11) What we shall Learn
Tensors and Variables
⌨️ (0:12:12) Basics
⌨️ (0:19:26) Initialization and Casting
⌨️ (1:07:31) Indexing
⌨️ (1:16:15) Maths Operations
⌨️ (1:55:02) Linear Algebra Operations
⌨️ (2:56:21) Common TensorFlow Functions
⌨️ (3:50:15) Ragged Tensors
⌨️ (4:01:41) Sparse Tensors
⌨️ (4:04:23) String Tensors
⌨️ (4:07:45) Variables
Building Neural Networks with TensorFlow [Car Price Prediction]
⌨️ (4:14:52) Task Understanding
⌨️ (4:19:47) Data Preparation
⌨️ (4:54:47) Linear Regression Model
⌨️ (5:10:18) Error Sanctioning
⌨️ (5:24:53) Training and Optimization
⌨️ (5:41:22) Performance Measurement
⌨️ (5:44:18) Validation and Testing
⌨️ (6:04:30) Corrective Measures
Building Convolutional Neural Networks with TensorFlow [Malaria Diagnosis]
⌨️ (6:28:50) Task Understanding
⌨️ (6:37:40) Data Preparation
⌨️ (6:57:40) Data Visualization
⌨️ (7:00:20) Data Processing
⌨️ (7:08:50) How and Why ConvNets Work
⌨️ (7:56:15) Building Convnets with TensorFlow
⌨️ (8:02:39) Binary Crossentropy Loss
⌨️ (8:10:15) Training Convnets
⌨️ (8:23:33) Model Evaluation and Testing
⌨️ (8:29:15) Loading and Saving Models to Google Drive
Building More Advanced Models in Teno Convolutional Neural Networks with TensorFlow [Malaria Diagnosis]
⌨️ (8:47:10) Functional API
⌨️ (9:03:48) Model Subclassing
⌨️ (9:19:05) Custom Layers
Evaluating Classification Models [Malaria Diagnosis]
⌨️ (9:36:45) Precision, Recall and Accuracy
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from freeCodeCamp.org · freeCodeCamp.org · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
React: Production Server Setup Part 2 - Live Coding with Jesse
freeCodeCamp.org
cookies vs localStorage vs sessionStorage - Beau teaches JavaScript
freeCodeCamp.org
Browser history tutorial - Beau teaches JavaScript
freeCodeCamp.org
Graph Data Structure Intro (inc. adjacency list, adjacency matrix, incidence matrix)
freeCodeCamp.org
React: Parameterized Routing with Next.js - Live Coding with Jesse
freeCodeCamp.org
React: Dealing with jQuery Issues - Live Coding with Jesse
freeCodeCamp.org
setInterval and setTimeout: timing events - Beau teaches JavaScript
freeCodeCamp.org
Browser and Device Testing - Live Coding with Jesse
freeCodeCamp.org
Last Minute Updates - Live Coding with Jesse
freeCodeCamp.org
Post Launch Updates - Live Coding with Jesse
freeCodeCamp.org
React: Setting Up Google Analytics - Live Coding with Jesse
freeCodeCamp.org
React: Masonry Layout - Live Coding with Jesse
freeCodeCamp.org
Load Balancing Digital Ocean Droplets - Live Coding with Jesse
freeCodeCamp.org
try, catch, finally, throw - error handling in JavaScript
freeCodeCamp.org
Load Balancing: SSL Passthrough Setup - Live Coding with Jesse
freeCodeCamp.org
Graphs: breadth-first search - Beau teaches JavaScript
freeCodeCamp.org
React: Masonry Layout Part 2 - Live Coding with Jesse
freeCodeCamp.org
React: WordPress API Live Search - Live Coding with Jesse
freeCodeCamp.org
Creating WordPress Custom Post Types - Live Coding With Jesse
freeCodeCamp.org
Dates - Beau teaches JavaScript
freeCodeCamp.org
Miscellaneous Front End Updates - Live Coding with Jesse
freeCodeCamp.org
Merging a Pull Request from GitHub - Live Coding with Jesse
freeCodeCamp.org
React + Prettier + Standard JS - Live Coding with Jesse
freeCodeCamp.org
React: Sortable Responsive Table - Live Coding with Jesse
freeCodeCamp.org
Geolocation Sorting by Distance - Live Coding with Jesse
freeCodeCamp.org
Tradeoff Matrix - Agile Software Development
freeCodeCamp.org
The Definition of Ready - Agile Software Development
freeCodeCamp.org
Getting first React job without experience - Ask Preethi
freeCodeCamp.org
React: Google Analytics Click Tracking - Live Coding with Jesse
freeCodeCamp.org
Submitting a PR to an Open Source Project - Live Coding with Jesse
freeCodeCamp.org
Should I go back to school to get CS degree? - Ask Preethi
freeCodeCamp.org
Hero Section CSS Changes - Live Coding with Jesse
freeCodeCamp.org
Working Agreement - Agile Software Development
freeCodeCamp.org
A day at Pennybox with Co-Founder Reji Eapen
freeCodeCamp.org
React: Sorting and Filtering Data - Live Coding with Jesse
freeCodeCamp.org
React: Sorting and Filtering Data Part 2 - Live Coding with Jesse
freeCodeCamp.org
React: Building a New UI - Live Coding with Jesse
freeCodeCamp.org
Definition of Done - Agile Software Development
freeCodeCamp.org
Getting started with jQuery (tutorial) - Beau teaches JavaScript
freeCodeCamp.org
Making a React Blog with WordPress Content - Live Coding with Jesse
freeCodeCamp.org
React, NextJS, CSS - Live Coding with Jesse
freeCodeCamp.org
jQuery events - Beau teaches JavaScript
freeCodeCamp.org
React/NextJS Routing and WordPress API Custom Types - Live Coding with Jesse
freeCodeCamp.org
React: Working with API Data - Live Coding with Jesse
freeCodeCamp.org
React: Refactoring Components - Live Streaming with Jesse
freeCodeCamp.org
jQuery effects - Beau teaches JavaScript
freeCodeCamp.org
More React Refactoring - Live Coding with Jesse
freeCodeCamp.org
animate in jQuery - Beau teaches JavaScript
freeCodeCamp.org
"Finishing" My React Site - Live Coding with Jesse
freeCodeCamp.org
Starting a New React Project (P2D1) - Live Coding with Jesse
freeCodeCamp.org
React Project 2 Day 2: Learning Material UI - Live Coding with Jesse
freeCodeCamp.org
The Agile Manifesto - Agile Software Development
freeCodeCamp.org
jQuery: get and set with http, text, val, and attr - Beau teaches JavaScript
freeCodeCamp.org
React Project 2 Day 3 - Live Coding with Jesse
freeCodeCamp.org
The INVEST approach to product backlog items
freeCodeCamp.org
React Project 2 Day 4 - Live Coding with Jesse
freeCodeCamp.org
Chickens and Pigs - Agile Software Development
freeCodeCamp.org
React Project 2 Day 5 - Live Coding with Jesse
freeCodeCamp.org
jQuery: add and remove DOM elements - Beau teaches JavaScript
freeCodeCamp.org
React Project 2 Day 6 - Live Coding with Jesse
freeCodeCamp.org
More on: CV Basics
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
Want to get started with deep learning
Reddit r/deeplearning
Building a Deepfake Detector From Scratch — What Nobody Tells You
Medium · Deep Learning
Unfolding the Meandering Path: High-Dimensional Invariance and the Flat 2D Plane of Neural…
Medium · Deep Learning
Implementing Neural Style Transfer from Scratch: The Project That Started It All
Medium · Deep Learning
🎓
Tutor Explanation
DeepCamp AI