In this exercise, L = len (parameters)
parameters contains 4 elements: W1, W2, b1 and b2
Why is len(parameters) = 2?
In this exercise, L = len (parameters)
parameters contains 4 elements: W1, W2, b1 and b2
Why is len(parameters) = 2?
Why do you believe that len(parameters) is 2?
The given code in the exercise is the following. This mentions that L = 2:
def update_parameters(params, grads, learning_rate):
“”"
Update parameters using gradient descent
Arguments:
params -- python dictionary containing your parameters
grads -- python dictionary containing your gradients, output of L_model_backward
Returns:
parameters -- python dictionary containing your updated parameters
parameters["W" + str(l)] = ...
parameters["b" + str(l)] = ...
"""
parameters = copy.deepcopy(params)
L = len(parameters) // 2 # number of layers in the neural network
Please post a screen capture image.
That doesn’t say that the length is 2.
It says to take the length and apply floor division by 2.
The comment says why.
Got it. Coming from c++, I interpreted the ‘//’ as the comment symbol.