WongKinYiu / PyTorch_YOLOv4

PyTorch implementation of YOLOv4
1.87k stars 585 forks source link

[Layer support] How to implement a grouped softmax layer #357

Open CaptainEven opened 3 years ago

CaptainEven commented 3 years ago

Hi, i want to train multi-label classification using YOLO backbone, do you know how to implement a grouped softmax layer?

[softmax]
groups=8
WongKinYiu commented 3 years ago
  1. groups already in supported [parse_config.py], need not to do anything.
  2. add grouped softmax layer in [layers.py]
  3. add softmax layer in [models.py].
        elif mdef['type'] == 'softmax':
            g = mdef['groups']  # kernel size
            stride = mdef['stride']
            gsoftmax= yourImpGroupedSoftMaxInLayers(groups = g)
            modules = gsoftmax

note, if your softmax layer is an output layer, following yolo layer to implement.

CaptainEven commented 3 years ago

@WongKinYiu Thank you for the answer!

CaptainEven commented 3 years ago

@WongKinYiu Actually, my problem is i did not figure out a way to implement a Group Softmax layer(an output layer) in PyTorch.

torch.softmax

This API can not do grouping softmax, as far as i know... Do you happen to know about it?

WongKinYiu commented 3 years ago

Could you provide more information about group softmax you want to implement? Do you want to use it to replace classification part in yolo layer, or do you want to use it for classification only?