Fix default pooling layer type
authorDmitry Kurtaev <dmitry.kurtaev+github@gmail.com>
Sun, 17 Dec 2017 11:36:38 +0000 (14:36 +0300)
committerDmitry Kurtaev <dmitry.kurtaev+github@gmail.com>
Sun, 17 Dec 2017 13:46:40 +0000 (16:46 +0300)
modules/dnn/src/layers/pooling_layer.cpp

index 0574458..fab977b 100644 (file)
@@ -67,13 +67,14 @@ class PoolingLayerImpl : public PoolingLayer
 public:
     PoolingLayerImpl(const LayerParams& params)
     {
-        type = MAX;
         computeMaxIdx = true;
         globalPooling = false;
+        stride = Size(1, 1);
 
-        if (params.has("pool"))
+        if (params.has("pool") || params.has("kernel_size") ||
+            params.has("kernel_w") || params.has("kernel_h"))
         {
-            String pool = params.get<String>("pool").toLowerCase();
+            String pool = params.get<String>("pool", "max").toLowerCase();
             if (pool == "max")
                 type = MAX;
             else if (pool == "ave")
@@ -90,6 +91,8 @@ public:
             type = ROI;
             computeMaxIdx = false;
         }
+        else
+            CV_Error(Error::StsBadArg, "Cannot determine pooling type");
         setParamsFrom(params);
         ceilMode = params.get<bool>("ceil_mode", true);
         pooledSize.width = params.get<uint32_t>("pooled_w", 1);