[Test] Add bn layer training
authorJihoon Lee <jhoon.it.lee@samsung.com>
Thu, 23 Sep 2021 08:00:03 +0000 (17:00 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Thu, 30 Sep 2021 23:15:07 +0000 (08:15 +0900)
**Changes proposed in this PR:**
- Add batchnormalization layer test (for channel, width axis)

**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_layers_v2.tar.gz
test/input_gen/genLayerTests.py
test/unittest/layers/unittest_layers_batch_normalization.cpp

index 58de15e..1bdd69b 100644 (file)
Binary files a/packaging/unittest_layers_v2.tar.gz and b/packaging/unittest_layers_v2.tar.gz differ
index 76a1449..f8a16dc 100644 (file)
@@ -48,8 +48,13 @@ if __name__ == "__main__":
     record_single(fc, (3, 1, 1, 10), "fc_golden_plain")
     fc = K.layers.Dense(4)
     record_single(fc, (1, 1, 1, 10), "fc_golden_single_batch")
-
-# inspect_file("fc_golden.nnlayergolden")
-
-
+    bn = K.layers.BatchNormalization()
+    record_single(bn, (2, 4, 2, 3), "bn_golden_channels_training", {"training": True})
+    ## @todo add test for inference
+    record_single(bn, (2, 4, 2, 3), "bn_golden_channels_inference", {"training": False})
+    bn = K.layers.BatchNormalization()
+    record_single(bn, (2, 10), "bn_golden_width_training", {"training": True})
+    record_single(bn, (2, 10), "bn_golden_width_inference", {"training": False})
+
+# inspect_file("bn_golden_width_training.nnlayergolden")
 
index 7073e45..10035ec 100644 (file)
@@ -22,3 +22,14 @@ auto semantic_bn = LayerSemanticsParamType(
 
 INSTANTIATE_TEST_CASE_P(BatchNormalization, LayerSemantics,
                         ::testing::Values(semantic_bn));
+
+auto bn_basic_channels = LayerGoldenTestParamType(
+  nntrainer::createLayer<nntrainer::BatchNormalizationLayer>, {}, "2:4:2:3",
+  "bn_golden_channels_training.nnlayergolden");
+
+auto bn_basic_width = LayerGoldenTestParamType(
+  nntrainer::createLayer<nntrainer::BatchNormalizationLayer>, {}, "2:1:1:10",
+  "bn_golden_width_training.nnlayergolden");
+
+INSTANTIATE_TEST_CASE_P(BatchNormalization, LayerGoldenTest,
+                        ::testing::Values(bn_basic_channels, bn_basic_width));