pytorch-cifar icon indicating copy to clipboard operation
pytorch-cifar copied to clipboard

Resnet18 experiment results are inconsistent

Open zerolxf opened this issue 6 years ago • 11 comments

I did a simple experiment with ResNet18 , and achieve the precision, 93%. But I found that it was different from pytorch's implementation torchvision.models.

I used your code to train, and it's faster. And I used torchvision.models.resnet18() to train, the first few epochs converge more slowly.

The same parameters, but different results. I want to know what makes them different. The training process is as follows Resnet18 pytorch_resnet18

zerolxf avatar Jul 25 '19 07:07 zerolxf

The ResNet18 in the repo modified the convolution in the beginning and the fc layers to accommodate CIFAR-10 dataset, which is slightly different from the ResNet paper for running the ImageNet dataset. Maybe this is it?

ZHUANGHP avatar Jul 25 '19 07:07 ZHUANGHP

This may be the reason. Thank you very much, I don't know much about Resnet. I am just implementing some algorithms for comparison experiments.

zerolxf avatar Jul 25 '19 09:07 zerolxf

Another thing you should be aware which is not mentioned in the readme is that the models here are trained with data augmentation which in comparison should give better results if you train the same exact model on the same dataset but without augmentation.

kirk86 avatar Aug 22 '19 14:08 kirk86

Even in the resnet paper they define a different resnet layout for CIFAR10 which is different for resnet layout for IMAGENET. The configuration you see in the table in the paper is for INAGENET. Since CIFAR10 has smaller images all those downsamplings in the regular resnet will leave almost nothing in the end for fc layers. The specific resnet layout for CIFAR10 is defined in section 4.2 of the resnet paper. The ones that are already in torchvision modules are for imagenet. This repo uses the resnet layout for CIFAR10.

amirhfarzaneh avatar Oct 23 '19 23:10 amirhfarzaneh

I tried to add some tweaks to ResNet18 and got 94.22, but when I ran without any changes it achieved 94.85 (after a total of 100 epochs)... was it just luck?

liuyao12 avatar Nov 07 '19 15:11 liuyao12

Is that difference significant in the first place, I personally view such differences in my experiments even in the range of 1%-3% as not that significant. After all chasing % numbers should not be our goal.

kirk86 avatar Nov 07 '19 16:11 kirk86

I just saw others also achieved ~95% on ResNet18 (and was about to delete my comment).

I agree. My goal wasn't to chase numbers, but to test out my ideas, which no one would care if I don't have experimental support.

liuyao12 avatar Nov 07 '19 16:11 liuyao12

My goal was to test out my ideas, which no one would care if I don't have experimental support

Agreed!

kirk86 avatar Nov 07 '19 16:11 kirk86

The implementation of CIFAR in the original ResNet paper is reproduced in my repository, please see (https://github.com/Lornatang/ResNet-PyTorch/tree/master/examples/cifar) Thank you, please give me some suggestions.

Lornatang avatar Jan 23 '20 15:01 Lornatang

@Lornatang https://github.com/Lornatang/ResNet/tree/master/examples/cifar gives a 404.

psteinb avatar May 27 '20 10:05 psteinb

@psteinb New Link:https://github.com/Lornatang/ResNet-PyTorch/tree/master/examples/cifar

Lornatang avatar May 29 '20 15:05 Lornatang