Randl / MobileNetV2-pytorch

Impementation of MobileNetV2 in pytorch
https://arxiv.org/abs/1801.04381
MIT License
271 stars 83 forks source link

MobileNet2._make_stage might be wrong #10

Closed grace-gu closed 5 years ago

grace-gu commented 5 years ago

In model.py, function "_make_stage" of MobileNet2 might be wrong. Your code:

 # add more LinearBottleneck depending on number of repeats
        for i in range(1, len(self.c) - 1):
            name = stage_name + "_{}".format(i)
            module = self._make_stage(inplanes=self.c[i], outplanes=self.c[i + 1], n=self.n[i + 1],
                                      stride=self.s[i + 1],
                                      t=self.t, stage=i)
            modules[name] = module

t means expand_ratio, c means channels, n means repeat times and smeans stride. So you tried to repeat each bottleNeck depending on number of channels, and each time you used stride of other bottlneNecks.

Randl commented 5 years ago

List c stores number of output channels of ith layer, i.e., inputs of i+1th layer. Thus to build i+1th layer we need to take c[i] as input channel count and other parameters are obviously sit in something[i+1]. We start from index 2 since 0th layer is simple convolution and 1st bottleneck is built separately

grace-gu commented 5 years ago

I'm wrong. I understand it now. Thank you.