+1
-1
@@ -14,7 +14,7 @@ install:
|
||||
- mkdir build && cd build && cmake -DDEBUG=OFF -DPROFILE=OFF .. && make -j2
|
||||
|
||||
script:
|
||||
- travis_wait 30 ./bin/mlpack_test -p
|
||||
- CTEST_OUTPUT_ON_FAILURE=1 travis_wait 30 ctest -j2
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
||||
@@ -8,15 +8,15 @@ add_executable(mlpack_test
|
||||
akfn_test.cpp
|
||||
aknn_test.cpp
|
||||
ann_layer_test.cpp
|
||||
arma_extend_test.cpp
|
||||
armadillo_svd_test.cpp
|
||||
arma_extend_test.cpp
|
||||
aug_lagrangian_test.cpp
|
||||
binarize_test.cpp
|
||||
block_krylov_svd_test.cpp
|
||||
cf_test.cpp
|
||||
cli_test.cpp
|
||||
convolution_test.cpp
|
||||
convolutional_network_test.cpp
|
||||
convolution_test.cpp
|
||||
cosine_tree_test.cpp
|
||||
cv_test.cpp
|
||||
dbscan_test.cpp
|
||||
@@ -36,8 +36,8 @@ add_executable(mlpack_test
|
||||
imputation_test.cpp
|
||||
ind2sub_test.cpp
|
||||
init_rules_test.cpp
|
||||
kernel_test.cpp
|
||||
kernel_pca_test.cpp
|
||||
kernel_test.cpp
|
||||
kernel_traits_test.cpp
|
||||
kfn_test.cpp
|
||||
kmeans_test.cpp
|
||||
@@ -50,8 +50,8 @@ add_executable(mlpack_test
|
||||
linear_regression_test.cpp
|
||||
load_save_test.cpp
|
||||
local_coordinate_coding_test.cpp
|
||||
log_test.cpp
|
||||
logistic_regression_test.cpp
|
||||
log_test.cpp
|
||||
lrsdp_test.cpp
|
||||
lsh_test.cpp
|
||||
math_test.cpp
|
||||
@@ -69,27 +69,28 @@ add_executable(mlpack_test
|
||||
octree_test.cpp
|
||||
pca_test.cpp
|
||||
perceptron_test.cpp
|
||||
prefixedoutstream_test.cpp
|
||||
q_learning_test.cpp
|
||||
qdafn_test.cpp
|
||||
quic_svd_test.cpp
|
||||
radical_test.cpp
|
||||
randomized_svd_test.cpp
|
||||
range_search_test.cpp
|
||||
recurrent_network_test.cpp
|
||||
rectangle_tree_test.cpp
|
||||
recurrent_network_test.cpp
|
||||
regularized_svd_test.cpp
|
||||
rl_components_test.cpp
|
||||
rmsprop_test.cpp
|
||||
sa_test.cpp
|
||||
sdp_primal_dual_test.cpp
|
||||
sgd_test.cpp
|
||||
sgdr_test.cpp
|
||||
snapshot_ensembles.cpp
|
||||
serialization.hpp
|
||||
serialization.cpp
|
||||
serialization_test.cpp
|
||||
sgdr_test.cpp
|
||||
sgd_test.cpp
|
||||
sfinae_test.cpp
|
||||
smorms3_test.cpp
|
||||
snapshot_ensembles.cpp
|
||||
softmax_regression_test.cpp
|
||||
sort_policy_test.cpp
|
||||
sparse_autoencoder_test.cpp
|
||||
@@ -99,17 +100,12 @@ add_executable(mlpack_test
|
||||
svd_batch_test.cpp
|
||||
svd_incremental_test.cpp
|
||||
termination_policy_test.cpp
|
||||
timer_test.cpp
|
||||
tree_test.cpp
|
||||
tree_traits_test.cpp
|
||||
union_find_test.cpp
|
||||
svd_batch_test.cpp
|
||||
svd_incremental_test.cpp
|
||||
nystroem_method_test.cpp
|
||||
armadillo_svd_test.cpp
|
||||
ub_tree_test.cpp
|
||||
union_find_test.cpp
|
||||
vantage_point_tree_test.cpp
|
||||
prefixedoutstream_test.cpp
|
||||
timer_test.cpp
|
||||
)
|
||||
# Link dependencies of test executable.
|
||||
target_link_libraries(mlpack_test
|
||||
@@ -129,8 +125,44 @@ add_custom_command(TARGET mlpack_test
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
)
|
||||
|
||||
# For 'make test'.
|
||||
add_test (NAME mlpack_test
|
||||
COMMAND mlpack_test "--log_level=test_suite" # Set UTF runtime param
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/ # This is where test files are put.
|
||||
)
|
||||
# The list of long running parallel tests
|
||||
set(parallel_tests
|
||||
"SdpPrimalDualTest;SVDIncrementalTest;SVDBatchTest;"
|
||||
"LocalCoordinateCodingTest;FeedForwardNetworkTest;SparseAutoencoderTest;"
|
||||
"GMMTest;CFTest;ConvolutionalNetworkTest;HMMTest;LARSTest;"
|
||||
"LogisticRegressionTest")
|
||||
|
||||
# Add tests to the testing framework
|
||||
# Get the list of sources from the test target
|
||||
get_target_property(test_sources mlpack_test SOURCES)
|
||||
|
||||
# Go through the list of test sources and parse the test suite name
|
||||
foreach(test_file ${test_sources})
|
||||
# Regex for parsing files with AUTO_TEST_SUITE
|
||||
file(STRINGS ${test_file} test_suite REGEX "BOOST_AUTO_TEST_SUITE\\(.*")
|
||||
if(NOT "${test_suite}" STREQUAL "")
|
||||
# Get the substring of test_suite within brackets in test_name
|
||||
string(REGEX MATCH "\\(.*\\)" test_name ${test_suite})
|
||||
# Get the substring excluding the brackets, by calculating the indices
|
||||
string(LENGTH ${test_name} end_idx)
|
||||
math(EXPR end_idx "${end_idx} - 2")
|
||||
string(SUBSTRING ${test_name} "1" ${end_idx} test)
|
||||
# Add the test to the testing tool, test is the name of the test suite
|
||||
add_test(NAME ${test} COMMAND mlpack_test -t ${test} WORKING_DIRECTORY
|
||||
${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
# Regex for parsing files with FIXTURE_TEST_SUITE similarly
|
||||
file(STRINGS ${test_file} test_suite REGEX "BOOST_FIXTURE_TEST_SUITE\\(.*,")
|
||||
if(NOT "${test_suite}" STREQUAL "")
|
||||
# Get the substring of test_suite within brackets and comma in test_name
|
||||
string(REGEX MATCH "\\(.*," test_name ${test_suite})
|
||||
string(LENGTH ${test_name} end_idx)
|
||||
math(EXPR end_idx "${end_idx} - 2")
|
||||
string(SUBSTRING ${test_name} "1" ${end_idx} test)
|
||||
add_test(NAME ${test} COMMAND mlpack_test -t ${test} WORKING_DIRECTORY
|
||||
${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Use RUN_SERIAL for long running parallel tests
|
||||
set_tests_properties(${parallel_tests} PROPERTIES RUN_SERIAL TRUE)
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/**
|
||||
* @file layer_traits_test.cpp
|
||||
* @author Marcus Edel
|
||||
*
|
||||
* Test the LayerTraits class. Because all of the values are known at compile
|
||||
* time, this test is meant to ensure that uses of LayerTraits still compile
|
||||
* okay and react as expected.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#include <mlpack/core.hpp>
|
||||
|
||||
#include <mlpack/methods/ann/layer/layer_traits.hpp>
|
||||
#include <mlpack/methods/ann/layer/bias_layer.hpp>
|
||||
#include <mlpack/methods/ann/layer/multiclass_classification_layer.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "test_tools.hpp"
|
||||
|
||||
using namespace mlpack;
|
||||
using namespace mlpack::ann;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(LayerTraitsTest);
|
||||
|
||||
// Test the defaults.
|
||||
BOOST_AUTO_TEST_CASE(DefaultsTraitsTest)
|
||||
{
|
||||
// An irrelevant non-connection type class is used here so that the default
|
||||
// implementation of ConnectionTraits is chosen.
|
||||
bool b = LayerTraits<int>::IsBinary;
|
||||
BOOST_REQUIRE_EQUAL(b, false);
|
||||
|
||||
b = LayerTraits<int>::IsOutputLayer;
|
||||
BOOST_REQUIRE_EQUAL(b, false);
|
||||
|
||||
b = LayerTraits<int>::IsBiasLayer;
|
||||
BOOST_REQUIRE_EQUAL(b, false);
|
||||
}
|
||||
|
||||
// Test the BiasLayer traits.
|
||||
BOOST_AUTO_TEST_CASE(BiasLayerTraitsTest)
|
||||
{
|
||||
bool b = LayerTraits<BiasLayer<> >::IsBinary;
|
||||
BOOST_REQUIRE_EQUAL(b, false);
|
||||
|
||||
b = LayerTraits<BiasLayer<> >::IsOutputLayer;
|
||||
BOOST_REQUIRE_EQUAL(b, false);
|
||||
|
||||
b = LayerTraits<BiasLayer<> >::IsBiasLayer;
|
||||
BOOST_REQUIRE_EQUAL(b, true);
|
||||
}
|
||||
|
||||
// Test the MulticlassClassificationLayer traits.
|
||||
BOOST_AUTO_TEST_CASE(MulticlassClassificationLayerTraitsTest)
|
||||
{
|
||||
bool b = LayerTraits<MulticlassClassificationLayer<> >::IsBinary;
|
||||
BOOST_REQUIRE_EQUAL(b, false);
|
||||
|
||||
b = LayerTraits<MulticlassClassificationLayer<> >::IsOutputLayer;
|
||||
BOOST_REQUIRE_EQUAL(b, true);
|
||||
|
||||
b = LayerTraits<MulticlassClassificationLayer<> >::IsBiasLayer;
|
||||
BOOST_REQUIRE_EQUAL(b, false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END();
|
||||
@@ -1,92 +0,0 @@
|
||||
/**
|
||||
* @file lstm_peephole_test.cpp
|
||||
* @author Marcus Edel
|
||||
*
|
||||
* Tests the LSTM peepholes.
|
||||
*
|
||||
* mlpack is free software; you may redistribute it and/or modify it under the
|
||||
* terms of the 3-clause BSD license. You should have received a copy of the
|
||||
* 3-clause BSD license along with mlpack. If not, see
|
||||
* http://www.opensource.org/licenses/BSD-3-Clause for more information.
|
||||
*/
|
||||
#include <mlpack/core.hpp>
|
||||
|
||||
#include <mlpack/methods/ann/layer/lstm_layer.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "test_tools.hpp"
|
||||
|
||||
using namespace mlpack;
|
||||
using namespace mlpack::ann;
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(LSTMPeepholeTest);
|
||||
|
||||
/*
|
||||
* Test the peephole connections in the forward pass. The test is a modification
|
||||
* of the peephole test originally written by Tom Schaul.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(LSTMPeepholeForwardTest)
|
||||
{
|
||||
double state1 = 0.2;
|
||||
double state2 = 0.345;
|
||||
double state3 = -0.135;
|
||||
double state4 = 10000;
|
||||
|
||||
arma::colvec input, output;
|
||||
|
||||
LSTMLayer<> hiddenLayer0(1, 6, true);
|
||||
|
||||
hiddenLayer0.InGatePeepholeWeights() = arma::mat("3");
|
||||
hiddenLayer0.ForgetGatePeepholeWeights() = arma::mat("4");
|
||||
hiddenLayer0.OutGatePeepholeWeights() = arma::mat("5");
|
||||
|
||||
// Set the LSTM state to state1 (state = inGateActivation * cellActivation
|
||||
// = 1 / (1 + e^(-1000)) * tanh(atanh(0.2)) = 1 * 0.2 = 0.2).
|
||||
// outputActivation = outGateActivation * stateActivation
|
||||
// = tanh((0.2)) * (1 / (1 + e^1000)) = 0.
|
||||
input << state4 << state4 << std::atanh(state1) << -state4;
|
||||
hiddenLayer0.FeedForward(input, output);
|
||||
BOOST_REQUIRE_CLOSE(output(0), 0, 1e-3);
|
||||
|
||||
// Verify that the LSTM state is correctly stored.
|
||||
input.clear();
|
||||
input << -state4 << state4 << state4 << state4;
|
||||
hiddenLayer0.FeedForward(input, output);
|
||||
BOOST_REQUIRE_CLOSE(output(0), std::tanh(state1), 1e-3);
|
||||
|
||||
// Add state2 to the LSTM state.
|
||||
// state = state + forgateGateActivation * state(t - 1) = 0.345 + 1 * 0.2 =
|
||||
// 0.545
|
||||
input.clear();
|
||||
input << state4 << state4 << std::atanh(state2) << state4;
|
||||
hiddenLayer0.FeedForward(input, output);
|
||||
BOOST_REQUIRE_CLOSE(output(0), std::tanh(state1 + state2), 1e-3);
|
||||
|
||||
// Verify the peephole connection to the forgetgate (weight = 4) by
|
||||
// neutralizing its contibution and therefore dividing the LSTM state value
|
||||
// by 2.
|
||||
input.clear();
|
||||
input << -state4 << -(state1 + state2) * 4 << state4 << state4;
|
||||
hiddenLayer0.FeedForward(input, output);
|
||||
BOOST_REQUIRE_CLOSE(output(0), std::tanh((state1 + state2) / 2), 1e-3);
|
||||
|
||||
// Verify the peephole connection to the inputgate (weight = 3) by
|
||||
// neutralizing its contibution and therefore dividing the provided input
|
||||
// by 2.
|
||||
input.clear();
|
||||
input << -(state1 + state2) / 2 * 3 << -state4 << std::atanh(state3)
|
||||
<< state4;
|
||||
hiddenLayer0.FeedForward(input, output);
|
||||
BOOST_REQUIRE_CLOSE(output(0), std::tanh(state3 / 2), 1e-3);
|
||||
|
||||
// Verify the peephole connection to the outputgate (weight = 5) by
|
||||
// neutralizing its contibution and therefore dividing the provided output
|
||||
// by 2.
|
||||
input.clear();
|
||||
input << -state4 << state4 << state4 << -state3 / 2 * 5;
|
||||
hiddenLayer0.FeedForward(input, output);
|
||||
BOOST_REQUIRE_CLOSE(output(0), std::tanh(state3 / 2) / 2, 1e-3);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END();
|
||||
Reference in New Issue
Block a user