[Conv2d/Test] Add more test
authorJihoon Lee <jhoon.it.lee@samsung.com>
Mon, 10 May 2021 06:33:39 +0000 (15:33 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Mon, 24 May 2021 09:59:47 +0000 (18:59 +0900)
This patch adds test suggested at #1042

Resolves #1054

**Self evaluation:**
1. Build test: [X]Passed [ ]Failed [ ]Skipped
2. Run test: [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: Jihoon Lee <jhoon.it.lee@samsung.com>
packaging/unittest_models.tar.gz
test/input_gen/genModelTests.py
test/unittest/unittest_nntrainer_models.cpp

index 1e99594..0416a77 100644 (file)
Binary files a/packaging/unittest_models.tar.gz and b/packaging/unittest_models.tar.gz differ
index 665c60c..2dab887 100644 (file)
@@ -192,7 +192,42 @@ if __name__ == "__main__":
         file_name="conv_same_padding_multi_stride.info"
     )
 
-    conv_layer_tc(strides=(3, 3))(file_name="conv_uneven_strides.info", debug="summary")
+    conv_layer_tc(strides=(3, 3))(file_name="conv_uneven_strides.info")
+
+    record(
+        file_name="conv_uneven_strides2.info",
+        model=[
+            K.Input(shape=(2, 4, 4)),
+            K.layers.Conv2D(filters=2, kernel_size=(2, 2), strides=(1, 2)),
+            K.layers.Activation("sigmoid"),
+            K.layers.Flatten(),
+            K.layers.Dense(10),
+            K.layers.Activation("softmax"),
+        ],
+        optimizer=opt.SGD(learning_rate=0.1),
+        iteration=10,
+        input_shape=(3, 2, 4, 4),
+        label_shape=(3, 10),
+        loss_fn_str="cross_softmax",
+        # debug="summary"
+    )
+
+    record(
+        file_name="conv_uneven_strides3.info",
+        model=[
+            K.Input(shape=(2, 4, 4)),
+            K.layers.Conv2D(filters=2, kernel_size=(2, 2), strides=(2, 1)),
+            K.layers.Activation("sigmoid"),
+            K.layers.Flatten(),
+            K.layers.Dense(10),
+            K.layers.Activation("softmax"),
+        ],
+        optimizer=opt.SGD(learning_rate=0.1),
+        iteration=10,
+        input_shape=(3, 2, 4, 4),
+        label_shape=(3, 10),
+        loss_fn_str="cross_softmax",
+    )
 
     pool_layer_tc = lambda pool_layer: partial(
         record,
index 57f6b35..3775f49 100644 (file)
@@ -798,6 +798,32 @@ INI conv_uneven_strides(
   }
 );
 
+INI conv_uneven_strides2(
+  "conv_uneven_strides2",
+  {
+    nn_base + "learning_rate=0.1 | optimizer=sgd | loss=cross | batch_size=3",
+    I("input") + input_base + "input_shape=2:4:4",
+    I("conv2d_c1") + conv_base + "kernel_size = 2,2 | filters=2 | stride=1,2",
+    I("act_1") + sigmoid_base,
+    I("flatten", "type=flatten"),
+    I("outputlayer") + fc_base + "unit = 10",
+    I("act_2") + softmax_base
+  }
+);
+
+INI conv_uneven_strides3(
+  "conv_uneven_strides3",
+  {
+    nn_base + "learning_rate=0.1 | optimizer=sgd | loss=cross | batch_size=3",
+    I("input") + input_base + "input_shape=2:4:4",
+    I("conv2d_c1") + conv_base + "kernel_size = 2,2 | filters=2 | stride=2,1",
+    I("act_1") + sigmoid_base,
+    I("flatten", "type=flatten"),
+    I("outputlayer") + fc_base + "unit = 10",
+    I("act_2") + softmax_base
+  }
+);
+
 
 INI conv_same_padding_multi_stride(
   "conv_same_padding_multi_stride",
@@ -1027,6 +1053,8 @@ INSTANTIATE_TEST_CASE_P(
     mkModelTc(conv_same_padding, "3:1:1:10", 10),
     mkModelTc(conv_multi_stride, "3:1:1:10", 10),
     mkModelTc(conv_uneven_strides, "3:1:1:10", 10),
+    mkModelTc(conv_uneven_strides2, "3:1:1:10", 10),
+    mkModelTc(conv_uneven_strides3, "3:1:1:10", 10),
     mkModelTc(conv_same_padding_multi_stride, "3:1:1:10", 10),
     mkModelTc(conv_no_loss_validate, "3:1:1:10", 1),
     mkModelTc(conv_none_loss_validate, "3:1:1:10", 1),