Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-143

U-Net Downsample Count

Problem

Count how many times a U-Net can halve a spatial dimension before reaching 1: repeatedly floor-divide by 2 and count the steps.

The signature is unet_downsample_count(image_size). Return an integer.

Hint

This is the number of encoder stages in a typical U-Net.

Test cases

case 1
in: [256]
expected: 8
case 2
in: [224]
expected: 7
case 3
in: [32]
expected: 5
case 4
in: [64]
expected: 6
case 5
in: [28]
expected: 4
Starter codePython
def unet_downsample_count(image_size):
    # Your code here
    pass

5 test cases · run your code against them in the editor