Merge pull request #2652 from jeffin143/asyn-aug-test
Migrate Augmentated_rnn and Async_Learning Test to catch2
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
# mlpack test executable.
|
||||
add_executable(mlpack_test
|
||||
async_learning_test.cpp
|
||||
augmented_rnns_tasks_test.cpp
|
||||
callback_test.cpp
|
||||
cf_test.cpp
|
||||
dcgan_test.cpp
|
||||
@@ -88,6 +86,8 @@ add_executable(mlpack_catch_test
|
||||
ann_visitor_test.cpp
|
||||
armadillo_svd_test.cpp
|
||||
arma_extend_test.cpp
|
||||
async_learning_test.cpp
|
||||
augmented_rnns_tasks_test.cpp
|
||||
bayesian_linear_regression_test.cpp
|
||||
bias_svd_test.cpp
|
||||
binarize_test.cpp
|
||||
@@ -227,7 +227,6 @@ add_custom_command(TARGET mlpack_test
|
||||
|
||||
# The list of long running parallel tests
|
||||
set(parallel_tests
|
||||
"AsyncLearningTest;"
|
||||
"LocalCoordinateCodingTest;"
|
||||
"GMMTest;"
|
||||
"CFTest;"
|
||||
|
||||
@@ -24,17 +24,15 @@
|
||||
|
||||
#include <ensmallen.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "test_tools.hpp"
|
||||
#include "catch.hpp"
|
||||
|
||||
using namespace mlpack;
|
||||
using namespace mlpack::ann;
|
||||
using namespace mlpack::rl;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(AsyncLearningTest);
|
||||
|
||||
// Test async one step q-learning in Cart Pole.
|
||||
BOOST_AUTO_TEST_CASE(OneStepQLearningTest)
|
||||
TEST_CASE("OneStepQLearningTest", "[AsyncLearningTest]")
|
||||
{
|
||||
/**
|
||||
* This is for the Travis CI server, in your own machine you should use more
|
||||
@@ -106,11 +104,11 @@ BOOST_AUTO_TEST_CASE(OneStepQLearningTest)
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_REQUIRE_EQUAL(success, true);
|
||||
REQUIRE(success == true);
|
||||
}
|
||||
|
||||
// Test async one step Sarsa in Cart Pole.
|
||||
BOOST_AUTO_TEST_CASE(OneStepSarsaTest)
|
||||
TEST_CASE("OneStepSarsaTest", "[AsyncLearningTest]")
|
||||
{
|
||||
/**
|
||||
* This is for the Travis CI server, in your own machine you shuold use more
|
||||
@@ -184,11 +182,11 @@ BOOST_AUTO_TEST_CASE(OneStepSarsaTest)
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_REQUIRE_EQUAL(success, true);
|
||||
REQUIRE(success == true);
|
||||
}
|
||||
|
||||
// Test async n step q-learning in Cart Pole.
|
||||
BOOST_AUTO_TEST_CASE(NStepQLearningTest)
|
||||
TEST_CASE("NStepQLearningTest", "[AsyncLearningTest]")
|
||||
{
|
||||
/**
|
||||
* This is for the Travis CI server, in your own machine you shuold use more
|
||||
@@ -233,7 +231,7 @@ BOOST_AUTO_TEST_CASE(NStepQLearningTest)
|
||||
{
|
||||
size_t maxEpisode = 100000;
|
||||
if (testEpisodes > maxEpisode)
|
||||
BOOST_REQUIRE(false);
|
||||
REQUIRE(false);
|
||||
testEpisodes++;
|
||||
rewards[pos++] = reward;
|
||||
pos %= rewards.n_elem;
|
||||
@@ -249,5 +247,3 @@ BOOST_AUTO_TEST_CASE(NStepQLearningTest)
|
||||
agent.Train(measure);
|
||||
Log::Debug << "Total test episodes: " << testEpisodes << std::endl;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END();
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
#include <mlpack/methods/ann/augmented/tasks/add.hpp>
|
||||
#include <mlpack/methods/ann/augmented/tasks/score.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "test_tools.hpp"
|
||||
#include "catch.hpp"
|
||||
|
||||
using std::vector;
|
||||
using std::pair;
|
||||
@@ -51,8 +50,10 @@ class HardCodedCopyModel
|
||||
size_t zeroCnt = 0, oneCnt = 0;
|
||||
for (size_t i = 1; i < input.n_rows; i += 2)
|
||||
{
|
||||
size_t& addVar = (input.at(i, 0) == 0) ? zeroCnt : oneCnt;
|
||||
++addVar;
|
||||
if (input.at(i, 0) == 0)
|
||||
++zeroCnt;
|
||||
else
|
||||
++oneCnt;
|
||||
}
|
||||
assert(oneCnt % zeroCnt == 0);
|
||||
nRepeats = oneCnt / zeroCnt;
|
||||
@@ -158,7 +159,7 @@ class HardCodedAddModel
|
||||
predictors = predictors.t();
|
||||
predictors.reshape(3, predictors.n_elem / 3);
|
||||
assert(predictors.n_rows == 3);
|
||||
int num_A = 0, num_B = 0;
|
||||
size_t num_A = 0, num_B = 0;
|
||||
bool num = false; // True iff we have already seen the separating symbol.
|
||||
size_t cnt = 0;
|
||||
for (size_t i = 0; i < predictors.n_cols; ++i)
|
||||
@@ -219,12 +220,11 @@ class HardCodedAddModel
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(AugmentedRNNsTasks);
|
||||
|
||||
// Test of CopyTask instance generator.
|
||||
// The data from generator is fed to the dummy hard-coded model above
|
||||
// that should be able to solve the task perfectly.
|
||||
BOOST_AUTO_TEST_CASE(CopyTaskTest)
|
||||
TEST_CASE("CopyTaskTest", "[AugmentedRNNsTasks]")
|
||||
{
|
||||
// Check the setup on various lengths...
|
||||
for (size_t maxLen = 2; maxLen <= 16; ++maxLen)
|
||||
@@ -242,8 +242,7 @@ BOOST_AUTO_TEST_CASE(CopyTaskTest)
|
||||
arma::field<arma::mat> predResponse;
|
||||
model.Predict(testPredictor, predResponse);
|
||||
// A single failure is a failure.
|
||||
BOOST_REQUIRE_GE(SequencePrecision<arma::mat>(testResponse, predResponse),
|
||||
0.99);
|
||||
REQUIRE(SequencePrecision<arma::mat>(testResponse, predResponse) >= 0.99);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,7 +250,7 @@ BOOST_AUTO_TEST_CASE(CopyTaskTest)
|
||||
// Test of SortTask instance generator.
|
||||
// The data from generator is fed to the dummy hard-coded model above
|
||||
// that should be able to solve the task perfectly.
|
||||
BOOST_AUTO_TEST_CASE(SortTaskTest)
|
||||
TEST_CASE("SortTaskTest", "[AugmentedRNNsTasks]")
|
||||
{
|
||||
size_t bitLen = 5;
|
||||
for (size_t maxLen = 2; maxLen <= 16; ++maxLen)
|
||||
@@ -266,15 +265,14 @@ BOOST_AUTO_TEST_CASE(SortTaskTest)
|
||||
arma::field<arma::mat> predResponse;
|
||||
model.Predict(testPredictor, predResponse);
|
||||
// A single failure is a failure.
|
||||
BOOST_REQUIRE_GE(SequencePrecision<arma::mat>(testResponse, predResponse),
|
||||
0.99);
|
||||
REQUIRE(SequencePrecision<arma::mat>(testResponse, predResponse) >= 0.99);
|
||||
}
|
||||
}
|
||||
|
||||
// Test of AddTask instance generator.
|
||||
// The data from generator is fed to the dummy hard-coded model above
|
||||
// that should be able to solve the task perfectly.
|
||||
BOOST_AUTO_TEST_CASE(AddTaskTest)
|
||||
TEST_CASE("AddTaskTest", "[AugmentedRNNsTasks]")
|
||||
{
|
||||
for (size_t bitLen = 2; bitLen <= 16; ++bitLen)
|
||||
{
|
||||
@@ -288,9 +286,6 @@ BOOST_AUTO_TEST_CASE(AddTaskTest)
|
||||
arma::field<arma::mat> predResponse;
|
||||
model.Predict(testPredictor, predResponse);
|
||||
// A single failure is a failure.
|
||||
BOOST_REQUIRE_GE(SequencePrecision<arma::mat>(testResponse, predResponse),
|
||||
0.99);
|
||||
REQUIRE(SequencePrecision<arma::mat>(testResponse, predResponse) >= 0.99);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END();
|
||||
|
||||
Reference in New Issue
Block a user