# Resnet for 32x32 images

I am trying to program a ResNet for 32x32 images, and I came upon this tutorial https://towardsdatascience.com/resnets-for-cifar-10-e63e900524e0, but I am a bit confused about what it is saying. In the layer 1 section, it says to use filters of size {16, 32, 64} respectively, but the output is only 16 channels.

I really need help I have no idea how to move forward and I would really appreciate it if someone would help me.

Note that the way ResNets work is driven by the â€śskipâ€ť connections, right? So within one â€śblockâ€ť, you preserve the spatial dimensions and the number of channels, because they need to mesh with the skip connection. So the output they show as 32 x 32 x 16 is just the output of the first â€śblockâ€ť or layer, right? Then you feed it into layer 2 and youâ€™ll end up with 16 x 16 x 32 as the output of that. And so forth with reduced spatial and increased channel dimensions in the 3rd layer.

Thank you for responding. I didnâ€™t mean to demand anything, Iâ€™m sorry if thatâ€™s what it came across as. What I donâ€™t understand is they say to use 3 different filters in Layer 1, of sizes {16,32,64}, which would result in an output of channels 64.

1 Like

No, thatâ€™s not what they said. The point is that the inputs are images, so they have 3 channels. So that means the very first â€śblockâ€ť of layers takes 32 x 32 x 3 inputs. So each filter will have shape 3 x 3 x 3 and there are 16 of them in the very first Conv2D. But then the rest of them will have 3 x 3 x 16 and then the output of that first layer is 32 x 32 x 16, because you need â€śsameâ€ť padding in order to mesh with the skip layer.

Then in the next block the filters will be 3 x 3 x 16 and there will be 32 of them. And so forth.

Oh ok. Thanks for clarifying that. Does that mean there are only 6 layers? I thought its supposed to be ResNet50.

I donâ€™t know. Youâ€™ll need to read the blog post and the code a bit more carefully.

They gave this diagram for layer 1, so I guess each layer comprises 6 sublayers?

That looks like 4 layers to me. The 3 x 16 blue blocks are just the filters being depicted. Or maybe you could consider it 2 actual Conv2D layers and that last one is just the output of the addition of the output of layer 2 and the skip connection to produce the final output.

But really, they gave you the code. Why not read it and see?

1 Like

Whereâ€™s the code? All I saw was a step-through of the problem.

1 Like

Oh I see. Thanks very much for your time.

Do you mind sending me a screenshot? I live in another country so the website is blocked.

Itâ€™s just a github link. If you canâ€™t get to github, I donâ€™t want to be in a position of having to send you everything you could possibly want from github. As I mentioned above, this is a) not part of the course that Iâ€™m helping you with and b) I donâ€™t get paid to do this. I hope you will understand.

My suggestion is that you try using a VPN if you are on some restrictive network that wonâ€™t let you get to github.

I got to the site (my free VPN started working), but it says the site doesnâ€™t exist. Welp

Ok, sorry, that was a dead end. Sigh.

But I think the description of how to build the network is pretty clear from the write up in the blog post. So just build it with TF based on what we did in the various exercises like the ResNet assignment and the U-Net assignment (C4 W3 A2).

You may also check out the Resnet paper for its figure 3 and table 1 about the architecture. And I think the content of the paper has a pretty clear explanation of what is going on.