Hi everyone, I was going through the first lab for week 3 and could not understand this piece of code
2.1 Defining the Neural Network Structure
(n_x, n_y) = layer_sizes(X_norm, Y_norm)
I don’t understand what the function layer_sizes() does, however I think it has something to do with the number of examples. Any advice is much appreciated.
It’s all described in the instructions there and in the comments in the “docstring” of the function.
X is the array of input data samples. The shape of that array is:
n_x x m, where n_x is the number of features or elements in each data sample and m is the number of samples we are given.
Then Y is an array that gives the “labels” corresponding to each sample in X (each column of X). The label is a single value that gives you the correct answer for that sample. So the dimensions of Y are n_y x m, where n_y is the number of elements in each label, which is just 1 in this type of problem.
Then the purpose of the layer_sizes
function is to use the “shape” attributes of the input arrays X and Y to determine the values of n_x and n_y and return them as a python “tuple” with two elements.
It seems so obvious now. Thank you.
1 Like