Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About coral-cnn model #16

Open
konioyxgq opened this issue Jan 3, 2020 · 11 comments
Open

About coral-cnn model #16

konioyxgq opened this issue Jan 3, 2020 · 11 comments

Comments

@konioyxgq
Copy link

You used nn.AvgPool2d(7, stride=1, padding=2) at the end of the cnn network, the network input is 120 x 120, the input of pooling layer is 4 x 4, then after the pooling layer to get the output size is 2 x 2, these 4 values are the same. What's the point of this design? Or I've miscalculated it.

@rasbt
Copy link
Member

rasbt commented Jan 3, 2020

It wouldn't really matter in this case whether you choose

nn.AvgPool2d(4)

or

nn.AvgPool2d(7, stride=1, padding=2)

or in general any number >= 4.

In all cases all the values are averaged if the input to that layer is 4x4. It's been a while, but if I remember correctly, the reason why we have this particular avg pooling layer was that we were initially experimenting with larger input images also. But in the end we used 120x120 to make the comparison with the Niu et al 2016 paper more fair because that's what they used.

@rasbt rasbt closed this as completed Jan 3, 2020
@konioyxgq
Copy link
Author

You mean, all three choices get the same result? If it's the same, it's just a difference in parameter amounts. Right?

@rasbt
Copy link
Member

rasbt commented Jan 3, 2020

Yeah. AvgPooling doesn't have any parameters. It's just averaging the pixels.

@konioyxgq
Copy link
Author

Yes, but it affects the parameters of the full connection layer

@konioyxgq
Copy link
Author

One of the full connection layers is 512 x 1 and the other is 4 x 512

@rasbt
Copy link
Member

rasbt commented Jan 3, 2020

Oh I see. That's because of the padding=2 then and you may be right that there are duplicated values. We probably did this because we were initially working with larger images.

@konioyxgq
Copy link
Author

Well, so if the input here is 120 x 120, it should be changed to nn. AvgPool2d (4). There is no duplicate value in this, and the fully connected parameter becomes 512, which also reduces the amount of parameters and the amount of calculation。

@rasbt rasbt reopened this Jan 3, 2020
@rasbt
Copy link
Member

rasbt commented Jan 3, 2020

i agree

@konioyxgq
Copy link
Author

I think it's going to affect the training process and the results will be different. What do you think?

@rasbt
Copy link
Member

rasbt commented Jan 3, 2020

yeah, i think it could make a small difference. I don't think it will substantially change anything because these are just some redundancies; and it probably will also affect all models equally.

@rasbt
Copy link
Member

rasbt commented Jan 3, 2020

I got curious and am currently rerunning the experiments. Looks like speed is not affected (makes sense because of broadcasting in PyTorch/CUDA probably) but performance does seem to improve a bit. I will update things once I have all results. It may take a while though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants