Migrating GAN related tests and math tests to Catch2
This commit is contained in:
@@ -5,12 +5,10 @@ add_executable(mlpack_test
|
||||
callback_test.cpp
|
||||
cf_test.cpp
|
||||
cosine_tree_test.cpp
|
||||
dcgan_test.cpp
|
||||
drusilla_select_test.cpp
|
||||
emst_test.cpp
|
||||
fastmks_test.cpp
|
||||
facilities_test.cpp
|
||||
gan_test.cpp
|
||||
gmm_test.cpp
|
||||
hmm_test.cpp
|
||||
hoeffding_tree_test.cpp
|
||||
@@ -26,7 +24,6 @@ add_executable(mlpack_test
|
||||
log_test.cpp
|
||||
logistic_regression_test.cpp
|
||||
lsh_test.cpp
|
||||
math_test.cpp
|
||||
matrix_completion_test.cpp
|
||||
maximal_inputs_test.cpp
|
||||
mlpack_test.cpp
|
||||
@@ -59,7 +56,6 @@ add_executable(mlpack_test
|
||||
ub_tree_test.cpp
|
||||
union_find_test.cpp
|
||||
vantage_point_tree_test.cpp
|
||||
wgan_test.cpp
|
||||
main_tests/cf_test.cpp
|
||||
main_tests/det_test.cpp
|
||||
main_tests/emst_test.cpp
|
||||
@@ -108,11 +104,13 @@ add_executable(mlpack_catch_test
|
||||
convolution_test.cpp
|
||||
cv_test.cpp
|
||||
dbscan_test.cpp
|
||||
dcgan_test.cpp
|
||||
decision_stump_test.cpp
|
||||
decision_tree_test.cpp
|
||||
det_test.cpp
|
||||
distribution_test.cpp
|
||||
feedforward_network_test.cpp
|
||||
gan_test.cpp
|
||||
image_load_test.cpp
|
||||
imputation_test.cpp
|
||||
io_test.cpp
|
||||
@@ -129,6 +127,7 @@ add_executable(mlpack_catch_test
|
||||
load_save_test.cpp
|
||||
loss_functions_test.cpp
|
||||
main.cpp
|
||||
math_test.cpp
|
||||
metric_test.cpp
|
||||
mean_shift_test.cpp
|
||||
nca_test.cpp
|
||||
@@ -155,6 +154,7 @@ add_executable(mlpack_catch_test
|
||||
svd_incremental_test.cpp
|
||||
svdplusplus_test.cpp
|
||||
test_catch_tools.hpp
|
||||
wgan_test.cpp
|
||||
main_tests/adaboost_test.cpp
|
||||
main_tests/approx_kfn_test.cpp
|
||||
main_tests/bayesian_linear_regression_test.cpp
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
|
||||
#include <ensmallen.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "test_tools.hpp"
|
||||
#include "catch.hpp"
|
||||
#include "serialization.hpp"
|
||||
|
||||
using namespace mlpack;
|
||||
@@ -30,14 +29,12 @@ using namespace mlpack::math;
|
||||
using namespace mlpack::regression;
|
||||
using namespace std::placeholders;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(DCGANNetworkTest);
|
||||
|
||||
/*
|
||||
* Tests the DCGAN implementation on the MNIST dataset.
|
||||
* It's not viable to train on bigger parameters due to time constraints.
|
||||
* Please refer mlpack/models repository for the tutorial.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(DCGANMNISTTest)
|
||||
TEST_CASE("DCGANMNISTTest", "[DCGANNetworkTest]")
|
||||
{
|
||||
size_t dNumKernels = 32;
|
||||
size_t discriminatorPreTrain = 5;
|
||||
@@ -129,7 +126,7 @@ BOOST_AUTO_TEST_CASE(DCGANMNISTTest)
|
||||
double objVal = dcgan.Train(trainData, optimizer);
|
||||
|
||||
// Test that objective value returned by GAN::Train() is finite.
|
||||
BOOST_REQUIRE_EQUAL(std::isfinite(objVal), true);
|
||||
REQUIRE(std::isfinite(objVal) == true);
|
||||
|
||||
// Generate samples.
|
||||
Log::Info << "Sampling..." << std::endl;
|
||||
@@ -196,7 +193,7 @@ BOOST_AUTO_TEST_CASE(DCGANMNISTTest)
|
||||
* Tests the DCGAN implementation with minibatch layer on the MNIST dataset.
|
||||
* It's not viable to train on bigger parameters due to time constraints.
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DCGANMNISTTest)
|
||||
TEST_CASE("DCGANMNISTTest", "[DCGANNetworkTest]")
|
||||
{
|
||||
size_t dNumKernels = 32;
|
||||
size_t discriminatorPreTrain = 5;
|
||||
@@ -284,7 +281,7 @@ BOOST_AUTO_TEST_CASE(DCGANMNISTTest)
|
||||
double objVal = dcgan.Train(optimizer);
|
||||
|
||||
// Test that objective value returned by GAN::Train() is finite.
|
||||
BOOST_REQUIRE_EQUAL(std::isfinite(objVal), true);
|
||||
REQUIRE(std::isfinite(objVal) == true);
|
||||
|
||||
// Generate samples
|
||||
Log::Info << "Sampling..." << std::endl;
|
||||
@@ -350,7 +347,7 @@ BOOST_AUTO_TEST_CASE(DCGANMNISTTest)
|
||||
* It's currently not possible to run this every time due to time constraints.
|
||||
* Please refer mlpack/models repository for the tutorial.
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DCGANCelebATest)
|
||||
TEST_CASE("DCGANCelebATest", "[DCGANNetworkTest]")
|
||||
{
|
||||
size_t dNumKernels = 64;
|
||||
size_t discriminatorPreTrain = 300;
|
||||
@@ -470,5 +467,3 @@ BOOST_AUTO_TEST_CASE(DCGANCelebATest)
|
||||
Log::Info << "Output generated!" << std::endl;
|
||||
}
|
||||
*/
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END();
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
|
||||
#include <ensmallen.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "test_tools.hpp"
|
||||
#include "catch.hpp"
|
||||
#include "serialization.hpp"
|
||||
|
||||
using namespace mlpack;
|
||||
@@ -30,14 +29,12 @@ using namespace mlpack::math;
|
||||
using namespace mlpack::regression;
|
||||
using namespace std::placeholders;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(GANNetworkTest);
|
||||
|
||||
/*
|
||||
* Load pre trained network values
|
||||
* for generating distribution that
|
||||
* is close to N(4, 0.5)
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(GANTest)
|
||||
TEST_CASE("GANTest", "[GANNetworkTest]")
|
||||
{
|
||||
size_t generatorHiddenLayerSize = 8;
|
||||
size_t discriminatorHiddenLayerSize = 8;
|
||||
@@ -125,8 +122,8 @@ BOOST_AUTO_TEST_CASE(GANTest)
|
||||
double originalStd = arma::as_scalar(arma::stddev(
|
||||
generatedData.rows(dim, 2 * dim - 1), 0, 1));
|
||||
|
||||
BOOST_REQUIRE_LE(generatedMean - originalMean, 0.2);
|
||||
BOOST_REQUIRE_LE(generatedStd - originalStd, 0.2);
|
||||
REQUIRE(generatedMean - originalMean <= 0.2);
|
||||
REQUIRE(generatedStd - originalStd <= 0.2);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -134,7 +131,7 @@ BOOST_AUTO_TEST_CASE(GANTest)
|
||||
* It's not viable to train on bigger parameters due to time constraints.
|
||||
* Please refer mlpack/models repository for the tutorial.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(GANMNISTTest)
|
||||
TEST_CASE("GANMNISTTest", "[GANNetworkTest]")
|
||||
{
|
||||
size_t dNumKernels = 32;
|
||||
size_t discriminatorPreTrain = 5;
|
||||
@@ -217,8 +214,8 @@ BOOST_AUTO_TEST_CASE(GANMNISTTest)
|
||||
Log::Info << "Training..." << std::endl;
|
||||
std::stringstream stream;
|
||||
double objVal = gan.Train(trainData, optimizer, ens::ProgressBar(70, stream));
|
||||
BOOST_REQUIRE_GT(stream.str().length(), 0);
|
||||
BOOST_REQUIRE_EQUAL(std::isfinite(objVal), true);
|
||||
REQUIRE(stream.str().length() > 0);
|
||||
REQUIRE(std::isfinite(objVal) == true);
|
||||
|
||||
// Generate samples.
|
||||
Log::Info << "Sampling..." << std::endl;
|
||||
@@ -284,7 +281,7 @@ BOOST_AUTO_TEST_CASE(GANMNISTTest)
|
||||
* Create GAN network and test for memory sharing
|
||||
* between discriminator and gan predictors.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(GANMemorySharingTest)
|
||||
TEST_CASE("GANMemorySharingTest", "[GANNetworkTest]")
|
||||
{
|
||||
size_t generatorHiddenLayerSize = 8;
|
||||
size_t discriminatorHiddenLayerSize = 8;
|
||||
@@ -347,5 +344,3 @@ BOOST_AUTO_TEST_CASE(GANMemorySharingTest)
|
||||
CheckMatricesNotEqual(gan.Predictors().head_cols(trainData.n_cols),
|
||||
trainData);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END();
|
||||
|
||||
+285
-290
File diff suppressed because it is too large
Load Diff
@@ -20,8 +20,7 @@
|
||||
|
||||
#include <ensmallen.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "test_tools.hpp"
|
||||
#include "catch.hpp"
|
||||
#include "serialization.hpp"
|
||||
|
||||
using namespace mlpack;
|
||||
@@ -30,14 +29,12 @@ using namespace mlpack::math;
|
||||
using namespace mlpack::regression;
|
||||
using namespace std::placeholders;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(WGANNetworkTest);
|
||||
|
||||
/*
|
||||
* Tests the standard WGAN implementation on the MNIST dataset.
|
||||
* It's not viable to train on bigger parameters due to time constraints.
|
||||
* Please refer mlpack/models repository for the tutorial.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(WGANMNISTTest)
|
||||
TEST_CASE("WGANMNISTTest", "[WGANNetworkTest]")
|
||||
{
|
||||
size_t dNumKernels = 32;
|
||||
size_t discriminatorPreTrain = 5;
|
||||
@@ -131,7 +128,7 @@ BOOST_AUTO_TEST_CASE(WGANMNISTTest)
|
||||
double objVal = wgan.Train(trainData, optimizer);
|
||||
|
||||
// Test that objective value returned by GAN::Train() is finite.
|
||||
BOOST_REQUIRE_EQUAL(std::isfinite(objVal), true);
|
||||
REQUIRE(std::isfinite(objVal) == true);
|
||||
|
||||
// Generate samples.
|
||||
Log::Info << "Sampling..." << std::endl;
|
||||
@@ -198,7 +195,7 @@ BOOST_AUTO_TEST_CASE(WGANMNISTTest)
|
||||
* It's not viable to train on bigger parameters due to time constraints.
|
||||
* Please refer mlpack/models repository for the tutorial.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(WGANGPMNISTTest)
|
||||
TEST_CASE("WGANGPMNISTTest","[WGANNetworkTest]")
|
||||
{
|
||||
size_t dNumKernels = 32;
|
||||
size_t discriminatorPreTrain = 5;
|
||||
@@ -293,7 +290,7 @@ BOOST_AUTO_TEST_CASE(WGANGPMNISTTest)
|
||||
double objVal = wganGP.Train(trainData, optimizer);
|
||||
|
||||
// Test that objective value returned by GAN::Train() is finite.
|
||||
BOOST_REQUIRE_EQUAL(std::isfinite(objVal), true);
|
||||
REQUIRE(std::isfinite(objVal) == true);
|
||||
|
||||
// Generate samples.
|
||||
Log::Info << "Sampling..." << std::endl;
|
||||
@@ -354,5 +351,3 @@ BOOST_AUTO_TEST_CASE(WGANGPMNISTTest)
|
||||
CheckMatrices(orgPredictions, textPredictions);
|
||||
CheckMatrices(orgPredictions, binaryPredictions);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END();
|
||||
|
||||
Reference in New Issue
Block a user