gpleiss / efficient_densenet_pytorch

A memory-efficient implementation of DenseNets
MIT License
1.52k stars 327 forks source link

Input data size #30

Closed g5996706 closed 6 years ago

g5996706 commented 6 years ago

Hi, thanks for this efficient densenet code. I have some problems. I try to use different input data size to train the model, If the size is smaller than 64 64 that will be no problem but if the size is bigger than 64 64 the errors will appear. RuntimeError: size mismatch at /pytorch/torch/lib/THC/generic/THCTensorMathBlas.cu:247 Can you point me how to fix it? Thank you so much.

gpleiss commented 6 years ago

@g5996706 this model is a classification model, so it's designed to take inputs of fixed size. With small_inputs=True (the default option) passed to the constructor (See the docstring), the network is designed to handle 32x32 images, such as CIFAR or SVHN images. With small_inputs=False, the network is designed to handle 224x224 images, which is the standard ImageNet image size.

g5996706 commented 6 years ago

Thank you for your answer. If I want to use the 224 224 as input ,in addition to setting small_inputs=False , should I change any other places? I think the code "self.avgpool_size = 8 if small_inputs else 7" should be changed to "self.avgpool_size = 8 if small_inputs else 14" if the input size is 224 ,because "x = batch depth 224 224" after "features = self.features(x)" features = batch depth 14 * 14 , the avgpool_size should be 14.

Can you tell me am I right or I am wrong

gpleiss commented 6 years ago

Yes avgpool_size should become 7. You should also use a block_config with 4 blocks, rather than 3.