C1W4_Question for Implementing Loop in ResNet

Hi everyone. I have a question about the Residual Network. I don’t understand the rationale provided for changing 3 repeated residual blocks into the loop. The reason provided in the video is the “Don’t repeat yourself” programming principle, but I don’t see how they are related as 3 repeated residual blocks will give more trainable weights as compared to passing the data into the blocks 3 times.


Appreciate if any clarification could be provided. Thank you.

The point here is to automate programing so you don’t write the same code 3 times, it has nothing to do with trainable weights. The number of weights will be same if the number of blocks is the same.

Yea. However by turning 3 blocks into 1 block with loops, it fundamentally change the architecture of the model and not just the programming style. Yet, the rationale provided for this modification in the video is to not repeat code.

If the purpose is not to repeat code, isnt the correct way is to take advantage of the var function of Python, as we did in the graded assignment?

3 separate blocks vs. 1 loop running 3 times is the same as having 3 blocks!