Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add scale_channels, swish, logistic(sigmoid), avgpool ; add enet_coco(EfficientNetB0-Yolov3).cfg #172

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

thnkinbtfly
Copy link

@thnkinbtfly thnkinbtfly commented Dec 14, 2020

Added Features

Add followings:

  1. [scale_channels] layer with scale_wh=0
  2. swish and logistic activation functions
  3. [avgpool] layer, which is global average pool in darknet

Tested with enet_coco (I removed dropout layers from the original enet_coco.cfg)

image

Reproduce test with enet_coco

  1. git clone the tkDNN forked darknet.

  2. git apply following patch file to the forked darknet. Note that if you don't change the BN epsilon (different BN epsilon from the forked darknet #167), the final output will fail to be similar.

diff --git a/src/blas.c b/src/blas.c
index 7bfc752..8d3ddd8 100644
--- a/src/blas.c
+++ b/src/blas.c
@@ -289,7 +289,7 @@ void normalize_cpu(float *x, float *mean, float *variance, int batch, int filter
         for(f = 0; f < filters; ++f){
             for(i = 0; i < spatial; ++i){
                 int index = b*filters*spatial + f*spatial + i;
-                x[index] = (x[index] - mean[f])/(sqrt(variance[f] + .000001f));
+                x[index] = (x[index] - mean[f])/(sqrt(variance[f] + .00001f));
             }
         }
     }
diff --git a/src/darknet.c b/src/darknet.c
index f7d6a81..21b0f83 100644
--- a/src/darknet.c
+++ b/src/darknet.c
@@ -506,6 +506,9 @@ void run_export(char *cfgfile, char *weightfile, char *out)
         } else if(l.type == SHORTCUT) {
             printf("export SHORTCUT\n");
             // no weights
+        } else if(l.type == SCALE_CHANNELS) {
+            printf("export SCALE_CHANNELS\n");
+            // no weights
         } else if(l.type == ROUTE) {
             printf("export ROUTE\n");
             // no weights
@@ -515,6 +518,9 @@ void run_export(char *cfgfile, char *weightfile, char *out)
         } else if(l.type == MAXPOOL) {
             printf("export MAXPOOL\n");
             // no weights 
+        } else if(l.type == AVGPOOL) {
+            printf("export AVGPOOL\n");
+            // no weights
         } else if(l.type == REORG || l.type == REORG_OLD) {
             printf("export REORG\n");
             // no weights          
  1. download enet-coco weights from official darknet repo

  2. follow the steps to generate weights and input/outputs.
    Example :
    ./darknet export ../tkDNN/tests/darknet/cfg/enet-coco-wo-dropout.cfg enetb0-coco_final.weights layers

  3. build tkDNN and

cd build
mkdir enet_coco_wo_dropout
cp -r ../../darknet/layers enet_coco_wo_dropout/ && cp -r ../../darknet/debug enet_coco_wo_dropout
./test_enet_coco_wo_dropout

@thnkinbtfly thnkinbtfly changed the title add scale_channels, swish, logistic(sigmoid), avgpool ; add enet_coco add scale_channels, swish, logistic(sigmoid), avgpool ; add enet_coco(EfficientNetB0-Yolov3).cfg Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant