Deep Learning Fundamentals
Transcript
Hello. In this lecture, we will learn about what deep learning is. In this lecture, we will give you a brief introduction about deep learning and we will talk about how deep learning algorithms “learn”. In the first lecture, we briefly learned what deep learning is. Deep learning is a type of machine learning algorithm that extracts features from input values by using multiple layers of formulas. Among the deep learning algorithms, famous algorithms include deep neural networks, deep belief networks, deep reinforcement learning, recurrent neural networks, and convolutional neural networks.
Almost all deep learning algorithms are implemented based on an algorithm called a neural network. Neural network is an algorithm that is used to implement AI, and we will show you how this algorithm works in a moment. Neural network algorithms are different from the term deep learning. Reinforcement learning models are a kind of deep learning algorithms, but reinforcement learning algorithms can be implemented without neural networks. However, since most modern deep learning algorithms are implemented based on neural networks, many people use the two terms interchangeably.
Artificial neural network algorithms are also called neural networks. This artificial neural network algorithm consists of a combination of artificial neurons. In fact, from a modern neuroscientific point of view, what computer scientists call artificial neural networks and artificial neurons work differently from the neurons in organisms. An artificial neuron is a combination of mathematical functions, and it is an artificial neural network algorithm that connects these functions to derive insights from input values.
One artificial neuron receives data and passes the input data to the activation function inside it. Then, the activation function performs an operation using the input value and returns the result. Activation functions vary and are usually created differently depending on the input data or the role of the neuron. If so, you may be wondering how this artificial neural network can process real-world data. To answer this, we first need to understand what the term "data" means.
In past lectures, we said that most phenomena in the world can be expressed numerically. “Data” means “facts that can be expressed”. And we know that a fact that can be expressed can also be expressed in a number. Therefore, you can think of artificial neural network models that process numbers as AI that process data. How an artificial neural network algorithm works can be briefly expressed as shown on the screen. Real-world data is transformed into "features" as it passes through the neural network. This feature may or may not be useful information derived from the real world.
There are many ways to connect artificial neurons. In this lecture, among many connection methods, we will learn based on a fully connected neural network in which one neuron is connected to other neurons in another layer in a one-to-many correspondence. Neural networks constructed in other ways work similarly to this one, so you won't have a hard time understanding neural network algorithms.
Hidden layer refers to all layers other than the layer that receives input data of the neural network or the layer that returns the computation result of the neural network. The picture on the screen is a picture of a fully connected neural network including one hidden layer. In a fully connected neural network, artificial neurons transmit their output to all neurons in the next layer. One artificial neuron has one or several input ports. And this port is connected to the output port of the previous layer or the data input to the neural network. One neuron can set a "weight" to each input port, and set which of the multiple input ports is more important.
One artificial neuron returns a value based on the sum of the weighted input values. Here, a function that obtains an output based on an input is called an "activation function". And the process of passing the value to the next layer is called "forward propagation". Let's look at a very simple single layer neural network example. We will create a neural network that detects spam emails. We can extract useful information such as sender, receiver, and the text from an email. Out of those information we can choose information we need to detect spam emails. AI models used in the market would use much more complex inputs but in this example, we will simply use 3 binary inputs, which means inputs in only true/false, extracted from the email.
First input is whether the sender is in blacklist, The second input is whether the word "password" is included in the email, and the third input is whether the "exe" extension file is attached. Now we will set the weight for each input. Earlier we said that weights can be used to set the importance of each port. Since the sender being in the blacklist means the email is a spam email by high chance, Let's set the weight of the first input port to 0.5.
Let's set the weights of the other two inputs to 0.2 and 0.3. Next we will set the activation function. Here, we will define an activation function to determine that an email is a spam email when the weighted input sum is greater than 0.5. Let's say that in an email, the sender of the email is blacklisted, the string "password" does not exist in the mail, and a file with the "exe" extension is attached.
If input is true, the value of input is set to 1, otherwise it is set to 0. When this e-mail information enters the neural network, The input is multiplied by the weight and then these values are added. And the weighted sum goes into the activation function. Since the weighted sum is 0.8, the value returned by the activation function is spam. And optimizing these weights to get more accurate results is called training the neural network model. The actual activation function returns a number, so it will return 1 if it is spam, and 0 otherwise.
Neural networks that are actually used have many more layers and have more inputs. However, the basic algorithm is similar. There are many machine learning models that can be implemented through artificial neural networks, but among them, we will explain how the model can learn based on the neural network model of the supervised learning approach. Supervised learning-based neural network models are the most popular models for implementing modern artificial intelligence models. Supervised learning artificial neural networks are trained based on the input and the correct answer output pairs.
The learning method of supervised learning model is similar to how human memorizes. For example, humans memorize the question and correct answer pairs for preparing a quiz. Artificial intelligence models of supervised learning approach also do "learning" in this way. When the artificial neural network model receives input data, it calculates and returns the output value through the activation functions defined in it. The result of this calculation may or may not be correct. The artificial neural network of supervised learning approach starts "training" from here.
Supervised learning-based artificial neural network models compare the output value of the model with the correct answer value. And to return an output similar to the answer the next time the same input is received, the weight values are changed. And in supervised learning based artificial neural network models, this process is called “training”. To explain it a little more easily, in a supervised learning-based artificial neural network model, when a model is given a problem, the internal function is changed in a way that returns an output that is similar to the correct answer.
For those who want to know more about the training process of an artificial neural network model, we will continue the explanation. However, if you do not want to learn the complicated mathematical contents, you can skip this part. I will try to explain it as simply as possible, but I will continue to explain it based on those who understand university calculus. And even if you don't understand this part, there is no problem in taking this course.
I mentioned earlier that the training of an artificial neural network model is accomplished by comparing the difference between the correct answer and the return value of the model. Here, the difference between the correct answer and the value returned by the model is called "error". And, you can think of the loss as the square of this error. You do not have to worry too much about the method of calculating the loss, just remember that the larger the error, the larger the loss, and the training of the artificial neural network model proceeds in the direction of decreasing the “loss” value.
In the previous slide, I described that the process of passing the output to the next layer through the activation function is forward propagation. Back propagation is the process of changing the weight of the previous layer based on the loss value. In the neural network, the outputs of the previous layer become the inputs of the next layer, and these inputs are multiplied by weights, and then added, and then enters the activation function.
From the last layer of the neural network, the output from the activation function is compared to the correct answer. And in the direction of reducing the loss value, the weights of the previous layer are changed. This process is called "training" of supervised learning-based neural network models, also called "back propagation". Let's see how "loss" adjusts the weights of each neuron. Mathematically, the correlation of two variables can be found through partial differentiation. If you do not know about partial differentiation, you can think of it as finding this relationship through "differentiation".
For those who do not know about differentiation, you can think of differentiation as finding the change in variable "b" according to the change in variable "a". The relationship between "loss" and "weight" can also be found by differentiating "loss" with respect to "weight". If you do not have a mathematical understanding of what we will be discussing now, you can skip the mathematical explanation.
The figure on the slide depicts the operation of a simple artificial neural network. Earlier, I explained that the input value multiplied by the weight goes into the activation function, and when the output comes out of the activation function, the loss is calculated based on the error between the correct answer and the output. From now on, I will explain mathematically how back propagation is performed in this artificial neural network.
Those who wish to understand this mathematically must have knowledge of calculus. We need to find the relationship between weights and losses. However, we cannot know the derivative of the loss with respect to weight. In this case, we can find this value by changing the expression. Any derivative can be found by converting it to the product of several other derivatives. This is called "chain rule". As shown in the slide, you just need to know that the derivative of loss with respect to weight can also be expressed as a product of three derivatives.
First of all, we can get the derivative of the loss with respect to "output" from the logs function as shown in the slide. The output of an artificial neuron is an activation function. There are several activation functions, but today I will explain the process of finding the derivative based on the sigmoid activation function. The sigmoid function is one of the functions used as the activation function in artificial neural networks. You don't need to know the details of the sigmoid function, but just make sure that the derivative of the sigmoid function is expressed as shown on the slide.
And, since the return value of the activation function is the output, we can see the activation function f as output. I mentioned earlier that the activation function receives an input multiplied by a weight. This is called a weighted sum, and since the argument of the sigmoid function is a weighted sum, the derivative of the sigmoid function is the derivative of the output with respect to the weighted sum. And, this derivative can be expressed as output multiplied by (1 – output).
In the previous slide, I said that the weighted sum is obtained by multiplying the input by the weight. Therefore, when the weighted sum is differentiated with respect to weight, the input, which is the coefficient of the weight, becomes the derivative. In conclusion, the derivative of loss with respect to weight can be obtained as the product of the three derivatives like shown. And you don't need to memorize this formula, you just need to know that it is possible to get the derivative.
Now, let's see how to use the derivative that indicates the change in loss according to the change in weight. First, let's draw the relationship between weight and loss in the form of a graph. We mentioned earlier that the loss value is the square of the error, and we need to adjust the weights to decrease the loss value. For example, If the graph showing the relationship between weight and loss is as follows, the weight should be changed to the point with the smallest loss value.
The derivative value calculated earlier is called "gradient". Gradient means the slope of the tangent line at a current weight point in the weight loss graph. If we draw the tangent line on the graph, it looks like this: gradient is the slope of this line. In a two-dimensional coordinate system, a line can be expressed in the form (slope * x + b). The "slope" of the tangent line in the previous slide is "gradient".
Gradient contains information about how the loss changes as the weight increases. If the gradient value is positive, it means that the "loss" increases as the "weight" increases, so to reduce the "loss", the "weight" must be adjusted to a smaller value. If the gradient is negative, the "loss" decreases as the "weight" increases, so we need to increase the "weight" to decrease the "loss".
New weight can be obtained using gradient as follows. Here, the learning rate is always positive, and can be set to a constant. For example, constants such as 0.0005 are often used. If you check the expression for finding the new weight, if the gradient is positive, the new weight will be smaller than the old weight. If the gradient is negative, the new weight will be larger than the old weight.
For example, in the graph shown in the slide, the gradient is positive, so the new weight is smaller than the old weight. And we can see that the loss is also smaller with the new weight. The larger the learning rate value, the larger the weight change. It's okay if you don't understand what I've explained so far. Instead, just remember that the loss affects setting the new weights. Reducing the loss is equivalent to reducing the error of the model, and you just need to know that changing the weights in the direction that the loss decreases is "back propagation".
Other neurons are updated in the same way. The weights of each layer are updated through the gradient calculated based on the chain rule, and the number of these calculations increases as the size of the neural network increases. And to perform these calculations quickly, the GPU is used. The process we have seen so far is the process of updating the weights based on one input and output pair. If there are multiple input and answer data pairs, this process must be repeated for all data. And, the training of the artificial neural network model is completed when updating the weights based on all data pairs is performed several times.
Running back propagation on all neurons on all training data is called 1 epoch. When training a neural network, we usually should train multiple epochs. Generally, if you have a large amount of data, you can complete model training with fewer training epochs. In an artificial neural network based on supervised learning, training refers to modifying the weights inside the neural network based on errors. The internal weight is set in the direction of reducing the error, and we call this process back propagation.
Inference is to obtain an output corresponding to an input value in an artificial intelligence model. Prediction is a type of inference, and in artificial neural network models, inference is also called forward propagation. Let's recap what we learned today. An artificial neural network is a set of functions composed of several activation functions. The artificial neural network divides the input data into multiple pieces (several ports). It analyzes the weight of each piece, and derives an output as a number. As mentioned in the previous time, because numbers can represent real-world data, artificial neural network models are utilized to derive new information from input data.
An artificial neural network can be viewed as an algorithm, which connects important parts of input values with new information. Most deep learning models are implemented using neural network techniques. And the neural network model based on unsupervised learning is also trained in the direction of reducing the loss. Exceptionally, deep learning models based on statistics or probabilistic algorithms exist, but a lot of knowledge of statistics or probability theory is required to understand these techniques.
If you want to study deep learning technology further in the future, we recommend that you take this course first and study additionally after having a basic understanding of deep learning techniques. However, there is a high chance that you will need a lot of knowledge about computer science or mathematics if you plan to study more difficult topics than those covered in this course. This concludes today's lecture. Next time we will learn about Keras. Deep Block by Omnis Labs Company. All rights reserved.

Ask anything
We've read this whole study set, so questions about it get the best answers.