Artificial intelligence is everywhere, be it in optical character recognition systems like this, which
help automatically extract information from files in object detection systems where the machine's able
to understand its environment.
In visual inspection systems, like in this case, where landing AI is using this artificial intelligence
tool to detect defects in electronic equipments.
We also have this in the health sector where we detect certain diseases in the human breast.
We have applications and image captioning, self-driving cars, voice transcriptions and question and
screen, just to name a few.
Before taking a look at these different tools will be using produce cars.
Let's start with an introduction to deep learning.
Deep learning is part of this vast computer science domain known as artificial intelligence.
Artificial intelligence itself involves teaching computers or machines do tasks which are usually done
by humans in classical, artificial intelligence or A.I. algorithms.
We feed the computer with a set of rules such that when given the inputs, the machine is able to produce
some output.
So supposing we want to build an AI algorithm which teaches a computer how to play the game of chess?
In that case, you'd pass in a set of well-defined rules such that the machine learns how to play the
game of chess based on the rules you've given it.
Now, in other subfields of artificial intelligence like machine learning, the way the machine learns
is quite different.
In this case, what we have is a machine learning model which has been given initially the inputs and
the outputs.
So the machine initially gets both the inputs and the outputs.
And usually we're dealing with a pretty large number of input output pairs.
Once the machine is done learning from this training examples which make up what we call the training
set, the machine is now fed with new input, which it hasn't ever seen based on just this input.
The model is now able to predict a new output.
Let's look at this simple example.
Yeah, we're having this detect run tool car damage detection notebook from Kaggle in which we have
this dataset which can permit us to train a model such that it learns how to correctly say whether a
car has been damaged or not.
In some cases, we may be able to say exactly at what point or in what region is the damage.
So looking at this car here, we see clearly that is a damaged car.
We could click on this other one.
See, we have this damage, this we have this damage and so on and so forth.
Before going any farther, let's understand how this machine learning models are built such that they
could learn from theater.
Firstly, we suppose we have this input data that this input image right here.
And then we have an output which is taking a value of say, one.
Now this value could be zero in the case where this image isn't that of a damaged car.
So if it's an undamaged car, we have the value zero.
In this case it is one.
So we have this our output.
Why would take this value one Now our system takes in this image.
It does some preprocessing and then we have our input x.
This is the input which gets into the model.
Now machine learning models could serve in several domains.
And so this preprocessing unit right here is highly dependent on the domain in which we're working on.
So if we're working in NLP, that's natural language processing and we have, for example, input which
a text will have this pre processing unit build such that we are able to convert that text into information
that the model will understand.
In this case we are having this input image which itself is made of pixels which each take values ranging
from 0 to 255.
So now we will not get into how this pre processing unit works.
We just understand that we have this pre processing and we have the input.
Now once we have this input, we get straight into the model right here.
So we'll just have this.
We suppose that here is our model.
We're using a very simplified model right here so that anyone could understand regardless of your background.
So you don't need to have a math degree to understand what we have to explain right here.
And trust me, if you could understand this, then you'll find because in this class will stress more
on how to use tools like TensorFlow and Huggin Face to train your machine learning models.
So let's look at this.
We have this input X, which we've seen already, and then this input is passed into these two functions.
We have F of x one and then we have f of x to the way f of x one is gotten from x is that we we have
in a constant.
So let's put in a constant here A we have a one and then right here we have a two.
Yeah, let's say we have B one and here we have B two.
So the way we get this F of x one is simply saying F of x one, that is we have this f of x one equals
x, this input times this constant a one which gives us now F of x one and then f of x two.
Is equals X times the constant a two.
Now notice how we have for each path its own constant.
So here we have f of x one, f of x two.
Now how do we get the output y?
We repeat the same process.
Yeah, we have Y equals B one times f of x one.
So we have b one times f of x one.
But notice that to obtain y, we also need to take into consideration this information which is passing
in this direction right here.
So what we have now is instead of just having B one times F of x one, we have b one times f of x one
plus b two times f of x two.
And if we make use of what we had right here, we see that F of x one is a one times x, so we have
a one times x f of x two is a two times x.
There we go.
We have seen how from this inputs we're able to obtain the outputs.
But how does this permit the machine to learn from this input data?
The way this works is we have here this constants which are known as weights.
So in case you new to machine learning, you would have to get accustomed to this term as you will be
using it very frequently.
So right here we have what we call the weights which define the way the model will produce an output
based on the inputs.
So this means that once you pass in an input like this image right here, this weights are modify,
right?
So let's suppose that we initialize the waist to a value of say 0.02 right here E two equals 0.02 and
this 0.0 to the 0.02.
So we have all these four values initialized at 0.02.
Then we'll have a certain output right here.
But then if we know that we have this input and we have an output of one, then with our machine learning
algorithm, we are able to modify this weights or this parameters right here such that once we get the
image.
We are able to get the corresponding output, which matches exactly what we expect.
That said, after training our model, instead of having a value of, say, 0.02 here, we may have
a value of six zero and yet we have a value of say, 0.3, yet we may have 0.4.
And then maybe I will have a value of 0.02.
Now, note that this is a very simplified model, and this is not the kind of models we use in practice
to learn from this kind of input data, like images, as we could see here.
But nonetheless, the principles still remain the same.
So coming back to our model, we have seen that we have this input to the model.
We have this intermediary values here which will call neurons.
We have this constants which are modified during the training process such that they are values permit
us to get certain outputs based on the inputs.
So yeah, we have our weights A, 1a2, B one, B two.
Now, in machine learning today and deep learning, we're used to having models which are over even
up to a billion parameters.
So you hear that this model or that other model has a billion parameters and that simply means we have
a billion of these types of constants.
So this is a tell you of how complex the models we deal with today have become.
We could complex the father's model by having this even more complex or better set deeper model by the
year will simply mean that we have stacked many more layers.
Now, note that here we had the weights, we had this neurons, and then we have the layer.
So understand that a layer is simply these nodes are nuance right here, which have a common input and
a common output.
And the way this layer or the way this neurons and the layer interact with the input in order to produce
the outputs is dependent on the type of layer we're working with.
Sometimes we may have dense layers.
Dense or what we call linear layers.
That's practically what we just saw.
Right now, that's where we had to take the input, multiply by some weight and then get the output.
So those are dense layers.
And then we could also have convolutional layers.
We'll see this subsequently.
We could have recurrent layers.
We could also have Transformers
and a host of many other different layers, which we could create so we could have your transformers.
Now, note that these are the most common which you'll use in practice.
That's in deep learning practice.
Now, we just mentioned the term deep learning.
It's in fact a branch of machine learning, but one in which specializes with models which have many
layers, which are stacked between the inputs and the outputs.
Hence the term deep learning.
Also note that this kind of machine learning model is known as a neural network.
So as we get into this course, one of the most important points to note is that the machine learning
model can't do much without proper data.
So make sure you treat your data very well by treating your data very well.
We simply mean gathering as much useful and clean data as possible.
To elaborate on that point concerning the useful data.
Let's consider that you've trained to model, which is able to take as input this kind of image and
then correctly say that this is a damaged car.
Now, supposing all these images were captured at the time and that you now have to do predictions or
the model has to do predictions in night time.
But because the model has been taught how to predict an input image, to contain a damaged car by using
images or inputs from daytime, this model may not perform very well.
From the moment you start building machine learning models and training them, you may be tempted to
think that a machine learning project is all about just building a model and then training it.
That's why we said previously that you have to be very careful about the way you deal with your data.
That said, let's look at our proposed machine learning development lifecycle.
When building a machine learning product will want to start with a task like in this case where we want
to detect damaged cars.
Our task will be that of taking in as input an image and predicting whether that image contains a damaged
car or not.
Then we'll move on to data and the stage of data.
We may make use of readily available data on the internet, or as in most cases, we would have to gather
our own data by ourselves.
Now imagine building a model based off a certain type of car, and then one in the test, that same
model on a completely different set of cars or completely different type of cars.
That obviously wouldn't be a great idea.
So upfront, we have to make sure we gather useful and representative data.
In the next step, we'll go straight into the modeling that is coming up with some machine learning
or deep learning model which will permit us to extract useful information from the inputs.
In this case, where we'll want to know, extract this information on whether the car is damaged or
not.
We would use typically convolutional neural networks.
We'll be looking at this shortly, so don't bother if you don't understand that.
From this we'll go straight into error sanctioning in error sanction.
And basically what we're doing is we're telling the model that in this example, as we have here, we
know that we have this image and that the output is meant to be a one saying that it's a damaged car.
So if our model readjusts, this is weights such that the output we have here is a zero, then we are
going to penalize the model for producing the wrong output since we know the right output.
And so this is that process of error sanctioning, which is part of our training process.
But before getting to training, we have to define our error function, loss function.
From this, we go straight into training and optimization using the gradient descent algorithm or a
variance of the gradient.
We'll look at this shortly.
And then from there, we have to evaluate our model so it doesn't suffice just to train the model.
We also have to evaluate this model from evaluation validation.
We get into testing the model that is actually seen whether this model works.
And from there, based on those performances, we are able to come up with some corrective measures.
So take note that we don't just build and then finally test.
But we also have this feedback where based on what we see, based on the performance of our model,
we are able to come up with some corrective measures at the different stages of our pipeline.
So we have, for example, the data so we could modify the data, even case models and performing very
well.
We could go ahead and gather much data or much more data, much more representative, useful and clean
data.
We could go ahead and modify the model, modify the error function, modify the training process, modify
the hyper parameters.
We're going to look at this shortly and ensure that we get the best out of our model.
But as we said right from the beginning, you shouldn't get scared, as in this course will be using
tools like TensorFlow hugging, face weights and biases and cube flow to help us in our machine learning
development lifecycle.
You now understand that deep learning is part of machine learning, which itself is part of artificial
intelligence.
Let's look at this categorization of machine learning algorithms.
We have supervised learning, unsupervised learning and reinforcement learning and supervised learning.
What we have is very similar to what we've seen already, where we have a model which has been trained
with input output pairs.
Whereas with unsupervised learning, we don't have this output during training, so we just pass on
the inputs and the model learns from this inputs.
This turns out to be very interesting in cases where getting the outputs is quite tedious.
Let's take this simple example.
Suppose we have this input right here.
That's an input speech.
Let's have this input speech.
And then we have this model which takes in this input speech and then transcribes it.
So suppose we say hello and then we transcribe this.
We have Hello.
We could build a model as a model like this, which does this transcription automatically.
And to build this kind of model, we need the inputs and the outputs.
Hence, this is a supervised learning problem.
But then if we're able to come up with a model which doesn't need this transcriptions, then all we'll
be doing is simply passing in this input voice.
And then the model automatically learns how to extract this vocal information automatically.
In that case, we're having an unsupervised learning problem.
We see that if we're the training model using the supervised learning technique and we need we're working
with, say, 100 K input audio sounds, we'll need a hundred K different transcriptions.
Whereas in the case of unsupervised learning, we could simply gather this voice data without bothering
ourselves on how or where we're going to get the transcriptions from.
This permits us not only easily trained such models, but also help in expanding or better still, democratizing
the use of such machine learning models as now someone in some village in India could just produce training
data in the local language very easily, since now we do not need the outputs that are the transcriptions
anymore.
So all we need to do is just passing the inputs and the model learns from this inputs.
The other type of machine learning is reinforcement learning.
To understand reinforcement learning, we are going to consider an environment, an interpreter, and
an agent.
The interpreter gets information about the environment and then passes it on to the agent.
And then the interpreter rewards the agents, depending on how well it took this action.
And so at the end, we have this agent, which is learning how to take the best actions since it's been
rewarded by the interpreter.
A simple application of this could be in the chess game.
So our environment is a chess board, and then we are trying to train these agents to make the best
moves based on the current state of the environment and also using the reward system from the interpreter.
One of the main reasons why machine learning and deep learning today have become very popular is thanks
to the fact that we have huge amounts of data available to the.
And it also turns out that as we increase the training data, that is the data we use in helping our
models better understand the environment, there is an increase in performance when it comes to deep
learning algorithms.
So where the classical machine learning algorithms start plateauing, the deep learning algorithms keep
performing even better.
That said, today we have specialized hardware like the GPUs and CPU's, which parameters train these
models way faster than what we would have done about 20 years ago.
Finally, we also have machine learning algorithms which are state of art methods in several domains
like computer vision and natural language processing.
Apart from this algorithms, we have amazing tools which permit developers all around the world come
up with deep learning and machine learning algorithms very quickly.
Before the days of tools like TensorFlow and PyTorch, developers had to write their own machine learning
algorithms all from scratch.
But today, that's no longer the case as we have a fully fledged TensorFlow ecosystem consisting of
different components which permit anybody load and pre process data for training these models, building,
training, reusing and evaluating the models and then deploying these models.
This deployment can be done on different platforms like the cloud, like mobile platforms, the web
and many other edge hardware devices.
Apart from deep learning libraries like TensorFlow, PyTorch or Fast AI, we also have domain focused
products like hugging face, now hugging faces made of thousands of different computer vision models
which help in solving different computer vision tasks like image classification, image segmentation,
image to image generation on conditional image generation, object detection, that estimation and video
classification.
And so picking one of these transformer based models does the white that which stands for vision transformer.
We could see here, for example, that if we pick this image of a tiger, you see it's going to classify
this correctly as a tiger.
We could go ahead and pick some other task.
Let's pick, say, object detection.
Yeah.
For example, you have this digital model.
Let's pick an example from year.
You could obviously drag an image or some image you have in your PC on the cloud.
But let's pick this one on.
Okay, Let's say football match.
There we go.
You see, all these different objects are detected.
You have persons, you have.
Yeah, persons, you have ball and that's it.
So you see that we have this pre-trained models available for this different tasks.
Now, when running machine learning experiments, it may happen that for even the same problem, you
run the experiment like 700 times and then you want to track those models which perform the best.
Apart from tracking the model.
You may also want to version even the data you are using the train these models.
Waiting biases is one tool which comes very handy in helping you manage your machine learning projects.
This is trusted by over 100,000 machine learning.
Practitioners could integrate very quickly in the common machine learning libraries.
You can see your tensorflow pytorch, keras psi kite hugging phase, xg boost.
And so to help you manage your machine learning projects while working or without changing much on your
initial code.
We also have this right here visualizations.
So you see we're going to look at this shortly, but we could have this type of hyper parameter tuning
visualizations and even the model prediction visualizations.
Lastly, we could collaborate in real time.
So if you're on a team and we want to discuss the current state of a machine learning project, weights
and biases is the right tool in this course.
The environment we shall be using in building and training our models would be the Google CoLab.
So you can head to Google Collab.
I could check out this
collab notebook which shows you how to make use of CoLab.
And so that's it for the section.
See you in the next section.