Week4 Assignment1 Exercise5 L_model_forward

There is a looping statement “for l in range(1, L):”. This loop covers all hidden layers.
My question is, surely this should be “for l in range(1, L**-1**):” ? In this way the loop would cover all except the final output layer which itself is covered by the sigmoid code in the next statement?

Best wishes,

Hi, in python, “in range” is up to, but NOT including, the specified upper limit. So we are actually not getting the last layer in this “for loop”.


1 Like