[FFmpeg-cvslog] libavfilter/dnn_native: Add multiple activation functions in dnn native

Xuewei Meng git at videolan.org
Wed May 22 05:28:36 EEST 2019


ffmpeg | branch: master | Xuewei Meng <xwmeng96 at gmail.com> | Tue May 21 14:52:49 2019 +0800| [ecc096513c32119341a1240b67778f3e24b4293e] | committer: Steven Liu

libavfilter/dnn_native: Add multiple activation functions in dnn native

Add "Leaky_relu" and "None" option in activation function.

Reviewed-by: Guo, Yejun <yejun.guo at intel.com>
Signed-off-by: Xuewei Meng <xwmeng96 at gmail.com>
Signed-off-by: Steven Liu <lq at onvideo.cn>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ecc096513c32119341a1240b67778f3e24b4293e
---

 libavfilter/dnn_backend_native.c | 5 +++++
 libavfilter/dnn_backend_native.h | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavfilter/dnn_backend_native.c b/libavfilter/dnn_backend_native.c
index fa3f20e4a2..3c8465a283 100644
--- a/libavfilter/dnn_backend_native.c
+++ b/libavfilter/dnn_backend_native.c
@@ -270,6 +270,11 @@ static void convolve(const float *input, float *output, const ConvolutionalParam
                     break;
                 case SIGMOID:
                     output[n_filter] = 1.0f / (1.0f + exp(-output[n_filter]));
+                    break;
+                case NONE:
+                    break;
+                case LEAKY_RELU:
+                    output[n_filter] = FFMAX(output[n_filter], 0.0) + 0.2 * FFMIN(output[n_filter], 0.0);
                 }
             }
             output += conv_params->output_num;
diff --git a/libavfilter/dnn_backend_native.h b/libavfilter/dnn_backend_native.h
index d70cd16387..7e4e943137 100644
--- a/libavfilter/dnn_backend_native.h
+++ b/libavfilter/dnn_backend_native.h
@@ -32,7 +32,7 @@
 
 typedef enum {INPUT, CONV, DEPTH_TO_SPACE} DNNLayerType;
 
-typedef enum {RELU, TANH, SIGMOID} DNNActivationFunc;
+typedef enum {RELU, TANH, SIGMOID, NONE, LEAKY_RELU} DNNActivationFunc;
 
 typedef enum {VALID, SAME, SAME_CLAMP_TO_EDGE} DNNConvPaddingParam;
 



More information about the ffmpeg-cvslog mailing list