PyTorch_YOLOv4 icon indicating copy to clipboard operation
PyTorch_YOLOv4 copied to clipboard

[Layer support] How to implement a grouped softmax layer

Open CaptainEven opened this issue 4 years ago • 4 comments

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

[softmax]
groups=8

CaptainEven avatar Aug 27 '21 08:08 CaptainEven

  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.

WongKinYiu avatar Aug 27 '21 10:08 WongKinYiu

@WongKinYiu Thank you for the answer!

CaptainEven avatar Sep 06 '21 02:09 CaptainEven

@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?

CaptainEven avatar Sep 06 '21 03:09 CaptainEven

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?

WongKinYiu avatar Sep 06 '21 04:09 WongKinYiu