DLS - Course 1, Week 4, Assignment 1, I have a question on Exercise 5 - L_Model_Forward, when is the number of NN Layers L = len(parameters) // 2? Why 2? Appreciate someone to clear my mind.
{code removed by mentor}
Hello @BHTan
We need to do a little bit of tracing back of L = len(parameters) // 2
to understand this. To begin with, as explained in the docstring, parameters
is the output of initialize_parameters_deep()
and if we go to that function, which is our exercise 2, its output is actually a dictionary that contains one W
parameter and one b
parameter for each layer. See there are 2 parameters per layer in that dictionary? It is therefore that we divide the length of that dictionary by 2 to get back the number of layers.
Cheers,
Raymond
PS1: That is a DLS assignment, so I will move the thread back to there for you
PS2: Your screenshot contains some assignment solution code, but since we can’t share it here, I will also remove it for you
1 Like