Transcript:
Welcome back! This week we will look at the basics of neural network programming -When implementing a neural network. There are some really important implementation techniques. For example, if you have a training set of m training samples. The familiar way to process the training set is probably using a for statement. Is to look at the data one by one. In fact, when dealing with a training set without having to use the for statement. You will want to take care of it. I’’ll, learn how to do it in this week’’s class. One more example when looking at the computational process of a normal neural network. After a step called forward pass or forward propagation, There are steps called reverse pass or backpropagation. So in this week’’s lesson, the computational process of learning a neural network. About why it is composed of forward propagation and backpropagation. You will also gain intuition. This week it’’s easier to do these principles. Let’’s use logistic regression to understand. Even if you’ve seen logistic regression before, I think there will be something to be gained through this class. Now let’s get started. Logistic regression is an algorithm for binary classification. Let’s set up the problem first. Let’’s take a look at an example of a binary classification problem. When these pictures are given as input, I want to print out how I categorized the two categories. When it is recognized as a cat picture, it prints 1 and I would like to print 0 if it is not a cat picture. At this point, we will display the output label as Y. Now let’s see how pictures are stored on the computer. Matching the red green blue channels in this photo Store, the three matrices separately. So if the input photo is 64 X 64 pixels. The three 64 x 64 matrice’s, Red green blue pixel indicates intensity value. But to show I drew much smaller matrices here. Instead of 64 X 64 as 5 x 4 matrices To turn these pixel intensity values into feature vectors. All pixel values of the feature vector X to be entered. I’’ll list them in one column. To spread the pixel values into a single vector. The feature vector X For a given picture. I will define it as follows. All of the pixel values in turn 255 231 etc List all the red pixels, Followed by 255 134 etc, To be a very long feature vector List, all red green blue pixel intensity values. in this photo. Therefore, this picture. For 64 X 64 the vector of X. The overall dimension will be 64 X 64 x 3 Because it contains the elements of these matrices. In this case, it is 12288 It’s the number that’s multiplied Of the input Feature Vector X, which is 12288 We will express the dimension as n_x. Sometimes for brevity. I’ll write the lowercase n. The goal of binary classification is Has a feature vector X representing the input picture 0 If the label Y for it is not 1 In other words, whether it is a picture of a cat or not Is to learn a predictable classifier. Now, let’’s introduce the notation we will use often. When representing just one training sample as a pair (x y) x is a feature vector on the N_X dimension Label. Y is 0 or 1 The training set takes m training samples. And will be marked as follows: The inputs and outputs of the first training sample (x^(1) y^(1)). From the second training sample (x^(2) y^(2)) Until the last training sample (x^(m) y^(m)). All together becomes the training set. We will denote the number of training samples in m. Sometimes to emphasize what it means, It can be written as m_train and for the test set. We will display the number of test sets as m_test Finally to make all the training samples more concise Matrix X as I’ll define The training set with input columns of X. It consists of x^(1) x^(2), etc. Let x^(1) be the first column of this matrix. X^(2) is the second column. Putting it in the mth column up to X^(m) completes the Matrix X. So when m is the number of training samples, X is m rows and consists of n_x rows. In other courses, X may have been defined differently Is to put the training sets in rows instead of columns of X from the transpose of X^(1) up to the transpose of X^(M), But it turns out that when implementing a neural network Much easier to implement with the method on the left to sum up X is an n_x × m matrix. If you implement it in Python With the Python command Xshape, We can know the dimensions of the matrix. In this case, (n_x m) is output means n_x × m matrix. Training samples x like this Can be grouped in a matrix. What about label Y to be printed Neural network implementation To make it easier? Putting the values of y into columns. Convenient, Therefore, Y is composed of y^(1) y^(2) to y^(m). Let’’s define it as a 1 x m matrix. Once again, using Python syntax. If you use Yshape, You can see that. The dimension of Y is (1 m) Later when implementing the neural network. Just like we defined X and Y here X or Y or see later Data for multiple training samples. It would be useful to put it in each row. These notations can be used with logistic regression. For the neural networks, we’ll see later. What is m or n? Or if you forgot another notation To make it easy to find I’’ve, put up a notation guide. Please refer to. Next time using this notation. Let’’s look at more logistic regression.