toandaominh1997 / EfficientDet.Pytorch

Implementation EfficientDet: Scalable and Efficient Object Detection in PyTorch
MIT License
1.44k stars 305 forks source link

How many parameters do you have? #114

Open HansolEom opened 4 years ago

HansolEom commented 4 years ago

From what I read in the paper, the effectivedet-d0 standard was 3.9m. But your model comes in 10.2m on a d0 basis. Did I calculate the parameters correctly?

model = EfficientDet(num_classes=args.num_class,
                     network=args.network,
                     W_bifpn=EFFICIENTDET[args.network]['W_bifpn'],
                     D_bifpn=EFFICIENTDET[args.network]['D_bifpn'],
                     D_class=EFFICIENTDET[args.network]['D_class']
                     )

def count_parameters(model):
    return sum(p.numel() for p in model.parameters() if p.requires_grad)
print (count_parameters(model))

python train.py --dataset COCO --dataset_root ~/data/coco/ --network efficientdet-d0 --batch_size 32

Loaded pretrained weights for efficientnet-b0 10261154

y78h11b09 commented 4 years ago

my model has 57.1m parameters on a d0 basis with 1601 classes and 401 attributes

y78h11b09 commented 4 years ago

dataset VG , network efficientdet-d0, batch_size 2

dvlshah commented 4 years ago

The paper has provided a deceptive number. If you manually calculate the total number of trainable parameters for d0, it is 10.2 Million parameters (backbone + biFpn + heads).

The paper has only provided the parameters (3.9M) for biFpn + heads.

The paper doesn't mention this explicitly.

rmcavoy commented 4 years ago

@dvlshah That is actually incorrect. See my newer issue on convolutions where I found that the paper is including the backbone (minus the classifier layer) and bifpn+ heads in its parameter calculations but that the convolutions in the bifpn+heads need to be depthwise separable (as explicitly stated in the paper for bifpn and implied heads) and you need to properly set Dclass and WClass which are set incorrectly in the current code.