Skip to content
DeepForgeby svx
All problems
EasyDeep Learningdl-239

VAE Encoder Stride Chain

Problem

List the spatial resolutions produced by the downsampling blocks of a VAE encoder, each of which halves the previous size with floor division.

The signature is vae_encoder_strides(input_size, num_downsamples). Return the list of resolutions after each downsample.

Hint

Stable Diffusion's VAE downsamples by a factor of 8 in total.

Test cases

case 1
in: [256,3]
expected: [128,64,32]
case 2
in: [512,4]
expected: [256,128,64,32]
case 3
in: [224,2]
expected: [112,56]
case 4
in: [32,1]
expected: [16]
Starter codePython
def vae_encoder_strides(input_size, num_downsamples):
    # Your code here
    pass

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