From f151fccce7252410e486bb5cf83a58385e1ad2ba Mon Sep 17 00:00:00 2001 From: Alex Nguyen Date: Sun, 22 Nov 2020 13:11:34 -0500 Subject: [PATCH] add test for copy and move constructor of noisy linear layer --- src/mlpack/tests/feedforward_network_test.cpp | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/mlpack/tests/feedforward_network_test.cpp b/src/mlpack/tests/feedforward_network_test.cpp index 7188f69f50..d828bb4075 100644 --- a/src/mlpack/tests/feedforward_network_test.cpp +++ b/src/mlpack/tests/feedforward_network_test.cpp @@ -153,6 +153,41 @@ TEST_CASE("CheckCopyMovingVanillaNetworkTest", "[FeedForwardNetworkTest]") CheckMoveFunction<>(model1, trainData, trainLabels, 1); } +/** + * Noisy Linear layer constructor test. + */ +TEST_CASE("CheckCopyMovingNoisyLinearTest", "[FeedForwardNetworkTest]") +{ + // Create training input by 5x5 matrix + arma::mat input = arma::randu(10,1); + // Create training output by 1 matrix + arma::mat output = arma::mat("1"); + + // Check copying constructor + FFN> *model1 = new FFN>(); + model1->Predictors() = input; + model1->Responses() = output; + model1->Add>(); + model1->Add>(10, 5); + model1->Add >(5, 1); + model1->Add>(); + + // Check whether copy constructor is working or not. + CheckCopyFunction<>(model1, input, output, 1); + + // Check moving constructor + FFN> *model2 = new FFN>(); + model2->Predictors() = input; + model2->Responses() = output; + model2->Add>(); + model2->Add>(10, 5); + model2->Add >(5, 1); + model2->Add>(); + + // Check whether move constructor is working or not. + CheckMoveFunction<>(model2, input, output, 1); +} + /** * Train the vanilla network on a larger dataset. */