Hi, I am confused about the He initialization code in the assignment, in exercise 3.
L is set to len(layers_dims) minus 1, but then the for loop goes to L+1
What’s the point of subtracting the length by 1 and then extending the loop range by one. Makes no difference (unless I am missing something). I get that the He adjustment is only supposed to go to the RelU layers, but the code provided doesn’t do that. It does all layers.
Hi @Yousif, welcome to Discourse.
Note that the iteration starts at 1, so I think is just to make the code consistent with the notation used in the course material. In this way you can initialize the weights inside the loop going from layer
l-1 to layer
I hope that helps.
Thanks for the welcome and reply @kampamocha but, respectfully, I think you missed my point.
My point is that the len-1 and L+1 are totally pointless together in the code. You can edit the code to remove the -1 and +1 and it will work the same. It just adds a layer of confusion.
If the code really wanted to reflect the course material then there shouldn’t be a L+1 in the for-loop range, to exclude the last layer (usually a sigmoid)
Do you see what I mean?
Hi @Yousif, I think now I understand what you mean, and looking at the previous exercises I agree that the inconsistency can be confusing. Thank you for pointing this out.