yuhuixu1993 / PC-DARTS

PC-DARTS:Partial Channel Connections for Memory-Efficient Differentiable Architecture Search
434 stars 108 forks source link

How to derive the final architecture? #39

Closed xiangzhluo closed 4 years ago

xiangzhluo commented 4 years ago

Hi Yuhui,

After I search on the CIFAR10 dataset, I get one type of genotype, which is familiar with the reported case in your paper.

However, when I derive the final architecture and calculate the FLOPs and latency, it seems a little strange.

For example, I run

from model import NetworkCIFAR as Network
import genotypes

genotype = genotype = eval("genotypes.%s" % "PCDARTS")

with torch.cuda.device(0):
    model = Network(36, 1000, 14, True, genotype)
    model.drop_path_prob = 0.3
    model.eval()
    flops, params =  get_model_complexity_info(model, (3, 224, 224), as_strings=True, print_per_layer_stat=True)
    print("{:<30}  {:<8}".format("Computational complexity: ", flops))
    print("{:<30}  {:<8}".format("Number of parameters: ", params))

The reported model complexity and number of parameters for the searched genotypes (with 14 layers)are as follows:

Computational complexity:       20.11 GMac
Number of parameters:           4.3 M  

But when I run the resnet50 for comparison:

from torchvision.models import resnet50

with torch.cuda.device(0):
    model = resnet50(pretrained=False)
    flops, params = get_model_complexity_info(model, (3, 224, 224), as_strings=True,
                                             print_per_layer_stat=True)
    print('{:<30}  {:<8}'.format('Computational complexity: ', flops))
    print('{:<30}  {:<8}'.format('Number of parameters: ', params))

The reported model complexity and number of parameters for resnet50 are as follows:

Computational complexity:       4.12 GMac
Number of parameters:           25.56 M 

The reported FLOPs in your paper on ImageNet setting is 597M. It seems there is something wrong with my derived final architecture. At your convenience, could you help to give clarifications about how to derive the final architecture? I will consider to deploy the searched model on some hardware devices and try to add some hardware-aware constraints for the overall design.

Additionally, the latency for the searched genotype (with 14 layers) is nearly ten times as the resnet50, which is unacceptable.

I am also an undergraduate from SJTU. Really thanks for your help. hahahaha

wuzhi19931128 commented 4 years ago

you need to import NetworkImagenet

xiangzhluo commented 4 years ago

you need to import NetworkImagenet

Yes, you are right.

But why the NetworkCIFAR's model complexity is so strange (even over 2G Mac)?

I will continue to figure it out. Thanks a lot for your gentle help.

xiangzhluo commented 4 years ago

And in the original paper, the author only reported the FLOPs under ImageNet setting, ignoring the FLOPs in CIFAR10.