Week 2: Resnet50 Tips Question


I’ve really enjoyed the course and I’m trying to implement my own resnet using a different dataset and was wondering if could get some tips.

Exercise 3 - ResNet50

In our assignment, from stage 2 to stage 4, we added an identity block at every stage. Instead of manually inputting all the blocks for every stage, is there a way to automatically add the identity blocks at every stage through a loop or something?

For example, if my script just finished running stage 2…

    X = convolutional_block(X, f = 3, filters = [64, 64, 256], s = 1)
    X = identity_block(X, 3, [64, 64, 256])
    X = identity_block(X, 3, [64, 64, 256])

…can I make it so that the next loop runs the above, but with an additional identity block? (but of course with the appropriate filters for stage 3)

Thanks in advance!

You can use a loop for this.

# here's an example
X = convolutional_block(...)
for _ in range(num_times):
	X = identity_block(X, ...)