Merge pull request #12 from mlpack/master
updating boost_to_catch2_2 with mlpack/master
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
name: Update Catch
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 10 1/16 * *'
|
||||
jobs:
|
||||
updateCatch:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Get Latest Catch Tagged Release
|
||||
id: catch-header
|
||||
run: |
|
||||
# Ping version information upstream.
|
||||
CATCH_RELEASE_JSON=$(curl -sL https://api.github.com/repos/catchorg/Catch2/releases/latest)
|
||||
CATCH_RELEASE_VERSION=$(jq -r ".tag_name" <<< "$CATCH_RELEASE_JSON" | tr -d v)
|
||||
echo ::set-output name=release_tag::$(echo $CATCH_RELEASE_VERSION)
|
||||
# Extract out version information from git repository.
|
||||
CATCH_VERSION_MAJOR=$(grep -i ".*#define CATCH_VERSION_MAJOR.*" src/mlpack/tests/catch.hpp | grep -o "[0-9]*")
|
||||
CATCH_VERSION_MINOR=$(grep -i ".*#define CATCH_VERSION_MINOR.*" src/mlpack/tests/catch.hpp | grep -o "[0-9]*")
|
||||
CATCH_VERSION_PATCH=$(grep -i ".*#define CATCH_VERSION_PATCH.*" src/mlpack/tests/catch.hpp | grep -o "[0-9]*")
|
||||
# Combine values to match release tag information.
|
||||
CATCH_VERSION_VALUE=${CATCH_VERSION_MAJOR}.${CATCH_VERSION_MINOR}.${CATCH_VERSION_PATCH}
|
||||
# Set the current release tag.
|
||||
echo ::set-output name=current_tag::$(echo $CATCH_VERSION_VALUE)
|
||||
|
||||
- name: Update Catch
|
||||
if: steps.catch-header.outputs.current_tag != steps.catch-header.outputs.release_tag
|
||||
env:
|
||||
CURRENT_TAG: ${{ steps.catch-header.outputs.current_tag }}
|
||||
RELEASE_TAG: ${{ steps.catch-header.outputs.release_tag }}
|
||||
run: |
|
||||
# Delete the catch.hpp.
|
||||
rm -f src/mlpack/tests/catch.hpp
|
||||
# Download the release.
|
||||
curl -sL https://github.com/catchorg/Catch2/releases/latest/download/catch.hpp -o src/mlpack/tests/catch.hpp
|
||||
|
||||
- name: Create Pull Request For Catch
|
||||
if: steps.catch-header.outputs.current_tag != steps.catch-header.outputs.release_tag
|
||||
uses: peter-evans/create-pull-request@v3
|
||||
with:
|
||||
commit-message: Upgrade Catch to ${{ steps.catch-header.outputs.release_tag }}
|
||||
title: Upgrade Catch to ${{ steps.catch-header.outputs.release_tag }}
|
||||
body: |
|
||||
Updates [catchorg/Catch2](https://github.com/catchorg/Catch2) to ${{ steps.catch-header.outputs.release_tag }}.
|
||||
Auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request).
|
||||
labels: update dependencies, automated PR
|
||||
branch: catch-header-updates-${{ steps.catch-header.outputs.release_tag }}
|
||||
@@ -0,0 +1,44 @@
|
||||
name: Update CLI11
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 10 1/16 * *'
|
||||
jobs:
|
||||
updateCLI11:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Get Latest CLI11 Tagged Release
|
||||
id: cli11-header
|
||||
run: |
|
||||
# Ping version information upstream.
|
||||
CLI11_RELEASE_JSON=$(curl -sL https://api.github.com/repos/CLIUtils/CLI11/releases/latest)
|
||||
CLI11_RELEASE_VERSION=$(jq -r ".tag_name" <<< "$CLI11_RELEASE_JSON" | tr -d v)
|
||||
echo ::set-output name=release_tag::$(echo $CLI11_RELEASE_VERSION)
|
||||
# Extract out version information from git repository.
|
||||
CLI11_VERSION_VALUE=$(grep -i ".*#define CLI11_VERSION.*" src/mlpack/bindings/cli/third_party/CLI/CLI11.hpp | grep -Po "(\d+\.)+\d+")
|
||||
# Set the current release tag.
|
||||
echo ::set-output name=current_tag::$(echo $CLI11_VERSION_VALUE)
|
||||
|
||||
- name: Update CLI11
|
||||
if: steps.cli11-header.outputs.current_tag != steps.cli11-header.outputs.release_tag
|
||||
env:
|
||||
CURRENT_TAG: ${{ steps.cli11-header.outputs.current_tag }}
|
||||
RELEASE_TAG: ${{ steps.cli11-header.outputs.release_tag }}
|
||||
run: |
|
||||
# Delete the CLI11.hpp.
|
||||
rm -f src/mlpack/bindings/cli/third_party/CLI/CLI11.hpp
|
||||
# Download the release.
|
||||
curl -sL https://github.com/CLIUtils/CLI11/releases/latest/download/CLI11.hpp -o src/mlpack/bindings/cli/third_party/CLI/CLI11.hpp
|
||||
|
||||
- name: Create Pull Request For CLI11
|
||||
if: steps.cli11-header.outputs.current_tag != steps.cli11-header.outputs.release_tag
|
||||
uses: peter-evans/create-pull-request@v3
|
||||
with:
|
||||
commit-message: Upgrade CLI11 to ${{ steps.cli11-header.outputs.release_tag }}
|
||||
title: Upgrade CLI11 to ${{ steps.cli11-header.outputs.release_tag }}
|
||||
body: |
|
||||
Updates [CLIUtils/CLI11](https://github.com/CLIUtils/CLI11) to ${{ steps.cli11-header.outputs.release_tag }}.
|
||||
Auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request).
|
||||
labels: update dependencies, automated PR
|
||||
branch: cli11-header-updates-${{ steps.cli11-header.outputs.release_tag }}
|
||||
+276
-807
File diff suppressed because it is too large
Load Diff
@@ -180,7 +180,7 @@ void PrintDocs(const std::string& bindingName,
|
||||
}
|
||||
|
||||
if (hasOutputOptions)
|
||||
{
|
||||
{
|
||||
// Next, iterate through the list of output options.
|
||||
cout << "### Output options" << endl;
|
||||
cout << endl;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
namespace cereal {
|
||||
|
||||
/**
|
||||
/**
|
||||
* This class is used as a shim for cereal to be able to serialize a raw pointer array.
|
||||
*/
|
||||
template<class T>
|
||||
@@ -84,7 +84,7 @@ ArrayWrapper<T> make_array(T*& t, S& s)
|
||||
* @param T C Style array.
|
||||
* @param S Size of the array.
|
||||
*/
|
||||
#define CEREAL_POINTER_ARRAY(T,S) cereal::make_array(T, S)
|
||||
#define CEREAL_POINTER_ARRAY(T, S) cereal::make_array(T, S)
|
||||
|
||||
} // namespace cereal
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Implementation of is_loading function.
|
||||
*
|
||||
* This implementation provides backward compatibilty with older
|
||||
* version of cereal that does not have Archive::is_loading struct.
|
||||
* version of cereal that does not have Archive::is_loading struct.
|
||||
*
|
||||
* 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
|
||||
@@ -28,11 +28,12 @@ struct is_cereal_archive
|
||||
{
|
||||
// Archive::is_loading is not implemented yet, so we can use std::is_same<>
|
||||
// to check if it is a loading archive.
|
||||
constexpr static bool value = std::is_same<Archive, cereal::BinaryInputArchive>::value ||
|
||||
//#if (BINDING_TYPE != BINDING_TYPE_R)
|
||||
std::is_same<Archive, cereal::JSONInputArchive>::value ||
|
||||
//#endif
|
||||
std::is_same<Archive, cereal::XMLInputArchive>::value;
|
||||
constexpr static bool value = std::is_same<Archive,
|
||||
cereal::BinaryInputArchive>::value ||
|
||||
// #if (BINDING_TYPE != BINDING_TYPE_R)
|
||||
std::is_same<Archive, cereal::JSONInputArchive>::value ||
|
||||
// #endif
|
||||
std::is_same<Archive, cereal::XMLInputArchive>::value;
|
||||
};
|
||||
|
||||
template<typename Archive>
|
||||
@@ -40,7 +41,7 @@ bool is_loading(
|
||||
const typename std::enable_if<
|
||||
is_cereal_archive<Archive>::value, Archive>::type* = 0)
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename Archive>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Implementation of is_saving function.
|
||||
*
|
||||
* This implementation provides backward compatibilty with older
|
||||
* version of cereal that does not have Archive::is_saving struct.
|
||||
* version of cereal that does not have Archive::is_saving struct.
|
||||
*
|
||||
* 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
|
||||
@@ -29,11 +29,12 @@ struct is_cereal_archive_saving
|
||||
{
|
||||
// Archive::is_saving is not implemented yet, so we can use std::is_same<>
|
||||
// to check if it is a loading archive.
|
||||
constexpr static bool value = std::is_same<Archive, cereal::BinaryOutputArchive>::value ||
|
||||
//#if (BINDING_TYPE != BINDING_TYPE_R)
|
||||
std::is_same<Archive, cereal::JSONOutputArchive>::value ||
|
||||
//#endif
|
||||
std::is_same<Archive, cereal::XMLOutputArchive>::value;
|
||||
constexpr static bool value = std::is_same<Archive,
|
||||
cereal::BinaryOutputArchive>::value ||
|
||||
// #if (BINDING_TYPE != BINDING_TYPE_R)
|
||||
std::is_same<Archive, cereal::JSONOutputArchive>::value ||
|
||||
// #endif
|
||||
std::is_same<Archive, cereal::XMLOutputArchive>::value;
|
||||
};
|
||||
|
||||
template<typename Archive>
|
||||
@@ -41,7 +42,7 @@ bool is_saving(
|
||||
const typename std::enable_if<
|
||||
is_cereal_archive_saving<Archive>::value, Archive>::type* = 0)
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename Archive>
|
||||
|
||||
@@ -32,9 +32,12 @@ template<typename T>
|
||||
struct HasSerializeFunction
|
||||
{
|
||||
template<typename C>
|
||||
using NonStaticSerialize = void(C::*)(cereal::XMLOutputArchive&, const uint32_t version);
|
||||
using NonStaticSerialize = void(C::*)(cereal::XMLOutputArchive&,
|
||||
const uint32_t version);
|
||||
|
||||
template<typename /* C */>
|
||||
using StaticSerialize = void(*)(cereal::XMLOutputArchive&, const uint32_t version);
|
||||
using StaticSerialize = void(*)(cereal::XMLOutputArchive&,
|
||||
const uint32_t version);
|
||||
|
||||
static const bool value = HasSerializeCheck<T, NonStaticSerialize>::value ||
|
||||
HasSerializeCheck<T, StaticSerialize>::value;
|
||||
|
||||
@@ -187,7 +187,7 @@ ElemType BLEU<ElemType, PrecisionType>::Evaluate(
|
||||
|
||||
template <typename ElemType, typename PrecisionType>
|
||||
template <typename Archive>
|
||||
void BLEU<ElemType, PrecisionType>::serialize(Archive& ar,
|
||||
void BLEU<ElemType, PrecisionType>::serialize(Archive& ar,
|
||||
const uint32_t version)
|
||||
{
|
||||
ar(CEREAL_NVP(maxOrder));
|
||||
|
||||
@@ -1131,7 +1131,7 @@ void BinarySpaceTree<MetricType, StatisticType, MatType, BoundType, SplitType>::
|
||||
if (node->left)
|
||||
stack.push(node->left);
|
||||
if (node->right)
|
||||
stack.push(node->right);
|
||||
stack.push(node->right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1431,7 +1431,7 @@ void RectangleTree<MetricType, StatisticType, MatType, SplitType, DescentType,
|
||||
{
|
||||
MatType*& datasetTemp = const_cast<MatType*&>(dataset);
|
||||
ar(CEREAL_POINTER(datasetTemp));
|
||||
}
|
||||
}
|
||||
|
||||
ar(CEREAL_NVP(points));
|
||||
ar(CEREAL_NVP(auxiliaryInfo));
|
||||
|
||||
@@ -23,7 +23,7 @@ template<typename InputDataType, typename OutputDataType>
|
||||
Add<InputDataType, OutputDataType>::Add(const size_t outSize) :
|
||||
outSize(outSize)
|
||||
{
|
||||
weights.set_size(outSize, 1);
|
||||
weights.set_size(WeightSize(), 1);
|
||||
}
|
||||
|
||||
template<typename InputDataType, typename OutputDataType>
|
||||
|
||||
@@ -122,8 +122,7 @@ AtrousConvolution<
|
||||
dilationWidth(dilationWidth),
|
||||
dilationHeight(dilationHeight)
|
||||
{
|
||||
weights.set_size((outSize * inSize * kernelWidth * kernelHeight) + outSize,
|
||||
1);
|
||||
weights.set_size(WeightSize(), 1);
|
||||
|
||||
// Transform paddingType to lowercase.
|
||||
std::string paddingTypeLow = paddingType;
|
||||
|
||||
@@ -165,9 +165,9 @@ class Concat
|
||||
}
|
||||
|
||||
//! Return the initial point for the optimization.
|
||||
const arma::mat& Parameters() const { return parameters; }
|
||||
const arma::mat& Parameters() const { return weights; }
|
||||
//! Modify the initial point for the optimization.
|
||||
arma::mat& Parameters() { return parameters; }
|
||||
arma::mat& Parameters() { return weights; }
|
||||
|
||||
//! Get the value of run parameter.
|
||||
bool Run() const { return run; }
|
||||
@@ -196,6 +196,9 @@ class Concat
|
||||
//! Get the axis of concatenation.
|
||||
size_t const& ConcatAxis() const { return axis; }
|
||||
|
||||
//! Get the size of the weight matrix.
|
||||
size_t WeightSize() const { return 0; }
|
||||
|
||||
/**
|
||||
* Serialize the layer
|
||||
*/
|
||||
@@ -225,8 +228,8 @@ class Concat
|
||||
//! Locally-stored network modules.
|
||||
std::vector<LayerTypes<CustomLayers...> > network;
|
||||
|
||||
//! Locally-stored model parameters.
|
||||
arma::mat parameters;
|
||||
//! Locally-stored model weights.
|
||||
OutputDataType weights;
|
||||
|
||||
//! Locally-stored delta visitor.
|
||||
DeltaVisitor deltaVisitor;
|
||||
|
||||
@@ -33,7 +33,7 @@ Concat<InputDataType, OutputDataType, CustomLayers...>::Concat(
|
||||
run(run),
|
||||
channels(1)
|
||||
{
|
||||
parameters.set_size(0, 0);
|
||||
weights.set_size(0, 0);
|
||||
}
|
||||
|
||||
template<typename InputDataType, typename OutputDataType,
|
||||
@@ -49,7 +49,7 @@ Concat<InputDataType, OutputDataType, CustomLayers...>::Concat(
|
||||
model(model),
|
||||
run(run)
|
||||
{
|
||||
parameters.set_size(0, 0);
|
||||
weights.set_size(0, 0);
|
||||
|
||||
// Parameters to help calculate the number of channels.
|
||||
size_t oldColSize = 1, newColSize = 1;
|
||||
|
||||
@@ -115,9 +115,9 @@ class DropConnect
|
||||
std::vector<LayerTypes<> >& Model() { return network; }
|
||||
|
||||
//! Get the parameters.
|
||||
OutputDataType const& Parameters() const { return parameters; }
|
||||
OutputDataType const& Parameters() const { return weights; }
|
||||
//! Modify the parameters.
|
||||
OutputDataType& Parameters() { return parameters; }
|
||||
OutputDataType& Parameters() { return weights; }
|
||||
|
||||
//! Get the output parameter.
|
||||
OutputDataType const& OutputParameter() const { return outputParameter; }
|
||||
@@ -150,6 +150,9 @@ class DropConnect
|
||||
scale = 1.0 / (1.0 - ratio);
|
||||
}
|
||||
|
||||
//! Return the size of the weight matrix.
|
||||
size_t WeightSize() const { return 0; }
|
||||
|
||||
/**
|
||||
* Serialize the layer.
|
||||
*/
|
||||
@@ -164,7 +167,7 @@ class DropConnect
|
||||
double scale;
|
||||
|
||||
//! Locally-stored weight object.
|
||||
OutputDataType parameters;
|
||||
OutputDataType weights;
|
||||
|
||||
//! Locally-stored delta object.
|
||||
OutputDataType delta;
|
||||
|
||||
@@ -108,7 +108,7 @@ template<typename Archive>
|
||||
void DropConnect<InputDataType, OutputDataType>::serialize(
|
||||
Archive& ar, const uint32_t /* version */)
|
||||
{
|
||||
// Delete the old network first, if needed.
|
||||
// Delete the old network first, if needed.
|
||||
if (cereal::is_loading<Archive>())
|
||||
{
|
||||
boost::apply_visitor(DeleteVisitor(), baseLayer);
|
||||
|
||||
@@ -164,6 +164,12 @@ class FastLSTM
|
||||
//! Get the number of output units.
|
||||
size_t OutSize() const { return outSize; }
|
||||
|
||||
//! Get the size of the weight matrix.
|
||||
size_t WeightSize() const
|
||||
{
|
||||
return 4 * outSize * inSize + 4 * outSize + 4 * outSize * outSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the layer
|
||||
*/
|
||||
|
||||
@@ -42,8 +42,7 @@ FastLSTM<InputDataType, OutputDataType>::FastLSTM(
|
||||
{
|
||||
// Weights for: input to gate layer (4 * outsize * inSize + 4 * outsize)
|
||||
// and output to gate (4 * outSize).
|
||||
weights.set_size(
|
||||
4 * outSize * inSize + 4 * outSize + 4 * outSize * outSize, 1);
|
||||
weights.set_size(WeightSize(), 1);
|
||||
}
|
||||
|
||||
template<typename InputDataType, typename OutputDataType>
|
||||
|
||||
@@ -38,7 +38,7 @@ Linear<InputDataType, OutputDataType, RegularizerType>::Linear(
|
||||
outSize(outSize),
|
||||
regularizer(regularizer)
|
||||
{
|
||||
weights.set_size(outSize * inSize + outSize, 1);
|
||||
weights.set_size(WeightSize(), 1);
|
||||
}
|
||||
|
||||
template<typename InputDataType, typename OutputDataType,
|
||||
@@ -70,7 +70,7 @@ template<typename InputDataType, typename OutputDataType,
|
||||
Linear<InputDataType, OutputDataType, RegularizerType>&
|
||||
Linear<InputDataType, OutputDataType, RegularizerType>::
|
||||
operator=(const Linear& layer)
|
||||
{
|
||||
{
|
||||
if (this != &layer)
|
||||
{
|
||||
inSize = layer.inSize;
|
||||
@@ -86,7 +86,7 @@ template<typename InputDataType, typename OutputDataType,
|
||||
Linear<InputDataType, OutputDataType, RegularizerType>&
|
||||
Linear<InputDataType, OutputDataType, RegularizerType>::
|
||||
operator=(Linear&& layer)
|
||||
{
|
||||
{
|
||||
if (this != &layer)
|
||||
{
|
||||
inSize = layer.inSize;
|
||||
|
||||
@@ -29,7 +29,7 @@ template<typename InputType, typename OutputType>
|
||||
void Softmin<InputDataType, OutputDataType>::Forward(
|
||||
const InputType& input,
|
||||
OutputType& output)
|
||||
{
|
||||
{
|
||||
InputType softminInput = arma::exp(-(input.each_row() -
|
||||
arma::min(input, 0)));
|
||||
output = softminInput.each_row() / sum(softminInput, 0);
|
||||
@@ -53,7 +53,7 @@ void Softmin<InputDataType, OutputDataType>::serialize(
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
|
||||
} // namespace ann
|
||||
} // namespace mlpack
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ MeanAbsolutePercentageError<InputDataType, OutputDataType>::Forward(
|
||||
const InputType& input,
|
||||
const TargetType& target)
|
||||
{
|
||||
InputType loss = arma::abs((input - target) / target);
|
||||
InputType loss = arma::abs((input - target) / target);
|
||||
return arma::accu(loss) * (100 / target.n_cols);
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ void MeanAbsolutePercentageError<InputDataType, OutputDataType>::Backward(
|
||||
const TargetType& target,
|
||||
OutputType& output)
|
||||
|
||||
{
|
||||
{
|
||||
output = (((arma::conv_to<arma::mat>::from(input < target) * -2) + 1) /
|
||||
target) * (100 / target.n_cols) ;
|
||||
target) * (100 / target.n_cols);
|
||||
}
|
||||
|
||||
template<typename InputDataType, typename OutputDataType>
|
||||
|
||||
@@ -21,7 +21,8 @@ namespace regression {
|
||||
* Serialize the Bayesian linear regression model.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void BayesianLinearRegression::serialize(Archive& ar, const uint32_t /* version */)
|
||||
void BayesianLinearRegression::serialize(Archive& ar,
|
||||
const uint32_t /* version */)
|
||||
{
|
||||
ar(CEREAL_NVP(centerData));
|
||||
ar(CEREAL_NVP(scaleData));
|
||||
|
||||
@@ -41,14 +41,25 @@ void LoadHMMAndPerformAction(const std::string& modelFile,
|
||||
{
|
||||
const std::string extension = data::Extension(modelFile);
|
||||
if (extension == "xml")
|
||||
LoadHMMAndPerformActionHelper<ActionType, cereal::XMLInputArchive>(modelFile, x);
|
||||
{
|
||||
LoadHMMAndPerformActionHelper<ActionType, cereal::XMLInputArchive>(
|
||||
modelFile, x);
|
||||
}
|
||||
else if (extension == "bin")
|
||||
LoadHMMAndPerformActionHelper<ActionType, cereal::BinaryInputArchive>(modelFile, x);
|
||||
{
|
||||
LoadHMMAndPerformActionHelper<ActionType, cereal::BinaryInputArchive>(
|
||||
modelFile, x);
|
||||
}
|
||||
else if (extension == "json")
|
||||
LoadHMMAndPerformActionHelper<ActionType, cereal::JSONInputArchive>(modelFile, x);
|
||||
{
|
||||
LoadHMMAndPerformActionHelper<ActionType, cereal::JSONInputArchive>(
|
||||
modelFile, x);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::Fatal << "Unknown extension '" << extension << "' for HMM model file "
|
||||
<< "(known: 'xml', 'json', 'bin')." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename ActionType,
|
||||
|
||||
@@ -573,7 +573,7 @@ void CheckSoftminActivationCorrect(const arma::colvec input,
|
||||
|
||||
// Test the activation function using the entire vector as input.
|
||||
arma::colvec activations;
|
||||
softmin.Forward(input,activations);
|
||||
softmin.Forward(input, activations);
|
||||
for (size_t i = 0; i < activations.n_elem; ++i)
|
||||
{
|
||||
REQUIRE(activations.at(i) == Approx(target.at(i)).epsilon(1e-5));
|
||||
@@ -606,8 +606,7 @@ void CheckSoftminDerivativeCorrect(const arma::colvec input,
|
||||
for (size_t i = 0; i < derivatives.n_elem; ++i)
|
||||
{
|
||||
REQUIRE(derivatives.at(i) == Approx(target.at(i)).epsilon(1e-5));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -86,15 +86,78 @@ TEST_CASE("WeightSetVisitorTest", "[ANNVisitorTest]")
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that WeightSizeVisitor works properly.
|
||||
* Test that WeightSizeVisitor works properly for linear layer.
|
||||
*/
|
||||
TEST_CASE("WeightSizeVisitorTest", "[ANNVisitorTest]")
|
||||
TEST_CASE("WeightSizeVisitorTestForLinearLayer", "[ANNVisitorTest]")
|
||||
{
|
||||
size_t randomSize = arma::randi(arma::distr_param(1, 100));
|
||||
size_t randomInSize = arma::randi(arma::distr_param(1, 100));
|
||||
size_t randomOutSize = arma::randi(arma::distr_param(1, 100));
|
||||
|
||||
LayerTypes<> linear = new Linear<>(randomSize, randomSize);
|
||||
LayerTypes<> linearLayer = new Linear<>(randomInSize, randomOutSize);
|
||||
|
||||
CheckCorrectnessOfWeightSize(linear);
|
||||
size_t weightSize = boost::apply_visitor(WeightSizeVisitor(), linearLayer);
|
||||
|
||||
CheckCorrectnessOfWeightSize(linearLayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that WeightSizeVisitor works properly for concat layer.
|
||||
*/
|
||||
TEST_CASE("WeightSizeVisitorTestForConcatLayer", "[ANNVisitorTest]")
|
||||
{
|
||||
LayerTypes<> concatLayer = new Concat<>();
|
||||
|
||||
size_t weightSize = boost::apply_visitor(WeightSizeVisitor(), concatLayer);
|
||||
|
||||
CheckCorrectnessOfWeightSize(concatLayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that WeightSizeVisitor works properly for fast lstm layer.
|
||||
*/
|
||||
TEST_CASE("WeightSizeVisitorTestForFastLSTMLayer", "[ANNVisitorTest]")
|
||||
{
|
||||
size_t randomInSize = arma::randi(arma::distr_param(1, 100));
|
||||
size_t randomOutSize = arma::randi(arma::distr_param(1, 100));
|
||||
|
||||
LayerTypes<> fastLSTMLayer = new FastLSTM<>(randomInSize, randomOutSize);
|
||||
|
||||
size_t weightSize = boost::apply_visitor(WeightSizeVisitor(), fastLSTMLayer);
|
||||
|
||||
CheckCorrectnessOfWeightSize(fastLSTMLayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that WeightSizeVisitor works properly for Add layer.
|
||||
*/
|
||||
TEST_CASE("WeightSizeVisitorTestForAddLayer", "[ANNVisitorTest]")
|
||||
{
|
||||
size_t randomOutSize = arma::randi(arma::distr_param(1, 100));
|
||||
|
||||
LayerTypes<> addLayer = new Add<>(randomOutSize);
|
||||
|
||||
size_t weightSize = boost::apply_visitor(WeightSizeVisitor(), addLayer);
|
||||
|
||||
CheckCorrectnessOfWeightSize(addLayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that WeightSizeVisitor works properly for Atrous Convolution Layer.
|
||||
*/
|
||||
TEST_CASE("WeightSizeVisitorTestForAtrousConvolutionLayer", "[ANNVisitorTest]")
|
||||
{
|
||||
size_t randomInSize = arma::randi(arma::distr_param(1, 100));
|
||||
size_t randomOutSize = arma::randi(arma::distr_param(1, 100));
|
||||
size_t randomKernelWidth = arma::randi(arma::distr_param(1, 100));
|
||||
size_t randomKernelHeight = arma::randi(arma::distr_param(1, 100));
|
||||
|
||||
LayerTypes<> atrousConvLayer = new AtrousConvolution<>(randomInSize,
|
||||
randomOutSize, randomKernelWidth, randomKernelHeight);
|
||||
|
||||
size_t weightSize = boost::apply_visitor(WeightSizeVisitor(),
|
||||
atrousConvLayer);
|
||||
|
||||
CheckCorrectnessOfWeightSize(atrousConvLayer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+5603
-1745
File diff suppressed because it is too large
Load Diff
@@ -1518,7 +1518,8 @@ TEST_CASE("DiagonalGaussianUnbiasedEstimatorTest", "[DistributionTest]")
|
||||
* the weighted mean and covariance reduce to the unweighted sample mean and
|
||||
* covariance.
|
||||
*/
|
||||
TEST_CASE("DiagonalGaussianWeightedParametersReductionTest", "[DistributionTest]")
|
||||
TEST_CASE("DiagonalGaussianWeightedParametersReductionTest",
|
||||
"[DistributionTest]")
|
||||
{
|
||||
arma::vec mean("2.5 1.5 8.2 3.1");
|
||||
arma::vec cov("1.2 3.1 8.3 4.3");
|
||||
|
||||
@@ -173,7 +173,8 @@ TEST_CASE("HoeffdingInformationGainBadSplitTest", "[HoeffdingTreeTest]")
|
||||
counts(1, 0) = 5;
|
||||
counts(1, 1) = 5;
|
||||
|
||||
REQUIRE(HoeffdingInformationGain::Evaluate(counts) == Approx(0.0).margin(1e-10));
|
||||
REQUIRE(HoeffdingInformationGain::Evaluate(counts) ==
|
||||
Approx(0.0).margin(1e-10));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,7 +217,8 @@ TEST_CASE("HoeffdingInformationGainZeroTest", "[HoeffdingTreeTest]")
|
||||
// When nothing has been seen, the information gain should be zero.
|
||||
arma::Mat<size_t> counts = arma::zeros<arma::Mat<size_t>>(10, 10);
|
||||
|
||||
REQUIRE(HoeffdingInformationGain::Evaluate(counts) == Approx(0.0).margin(1e-10));
|
||||
REQUIRE(HoeffdingInformationGain::Evaluate(counts) ==
|
||||
Approx(0.0).margin(1e-10));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,14 +227,22 @@ TEST_CASE("HoeffdingInformationGainZeroTest", "[HoeffdingTreeTest]")
|
||||
*/
|
||||
TEST_CASE("HoeffdingInformationGainRangeTest", "[HoeffdingTreeTest]")
|
||||
{
|
||||
REQUIRE(HoeffdingInformationGain::Range(1) == Approx(0).epsilon(1e-7));
|
||||
REQUIRE(HoeffdingInformationGain::Range(2) == Approx(1.0).epsilon(1e-7));
|
||||
REQUIRE(HoeffdingInformationGain::Range(3) == Approx(1.5849625).epsilon(1e-7));
|
||||
REQUIRE(HoeffdingInformationGain::Range(4) == Approx(2).epsilon(1e-7));
|
||||
REQUIRE(HoeffdingInformationGain::Range(5) == Approx(2.32192809).epsilon(1e-7));
|
||||
REQUIRE(HoeffdingInformationGain::Range(10) == Approx(3.32192809).epsilon(1e-7));
|
||||
REQUIRE(HoeffdingInformationGain::Range(100) == Approx(6.64385619).epsilon(1e-7));
|
||||
REQUIRE(HoeffdingInformationGain::Range(1000) == Approx(9.96578428).epsilon(1e-7));
|
||||
REQUIRE(HoeffdingInformationGain::Range(1) ==
|
||||
Approx(0).epsilon(1e-7));
|
||||
REQUIRE(HoeffdingInformationGain::Range(2) ==
|
||||
Approx(1.0).epsilon(1e-7));
|
||||
REQUIRE(HoeffdingInformationGain::Range(3) ==
|
||||
Approx(1.5849625).epsilon(1e-7));
|
||||
REQUIRE(HoeffdingInformationGain::Range(4) ==
|
||||
Approx(2).epsilon(1e-7));
|
||||
REQUIRE(HoeffdingInformationGain::Range(5) ==
|
||||
Approx(2.32192809).epsilon(1e-7));
|
||||
REQUIRE(HoeffdingInformationGain::Range(10) ==
|
||||
Approx(3.32192809).epsilon(1e-7));
|
||||
REQUIRE(HoeffdingInformationGain::Range(100) ==
|
||||
Approx(6.64385619).epsilon(1e-7));
|
||||
REQUIRE(HoeffdingInformationGain::Range(1000) ==
|
||||
Approx(9.96578428).epsilon(1e-7));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -795,7 +795,8 @@ TEST_CASE_METHOD(IOTestDestroyer, "OutputMatrixParamTest",
|
||||
remove("test.csv");
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(IOTestDestroyer, "OutputMatrixNoTransposeParamTest", "[IOTest]")
|
||||
TEST_CASE_METHOD(IOTestDestroyer, "OutputMatrixNoTransposeParamTest",
|
||||
"[IOTest]")
|
||||
{
|
||||
AddRequiredCLIOptions();
|
||||
|
||||
|
||||
@@ -190,7 +190,6 @@ TEST_CASE("TestSvecSmat", "[LinAlgTest]")
|
||||
for (size_t i = 0; i < 3; ++i)
|
||||
for (size_t j = 0; j < 3; ++j)
|
||||
REQUIRE(X(i, j) == Approx(Xtest(i, j)).epsilon(1e-9));
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("TestSparseSvec", "[LinAlgTest]")
|
||||
|
||||
@@ -120,7 +120,7 @@ TEST_CASE("LMNNInitialPointTest", "[LMNNTest]")
|
||||
for (int col = 0; col < 5; col++)
|
||||
{
|
||||
if (row == col)
|
||||
REQUIRE(initialPoint(row, col) == Approx( 1.0).epsilon(1e-7));
|
||||
REQUIRE(initialPoint(row, col) == Approx(1.0).epsilon(1e-7));
|
||||
else
|
||||
REQUIRE(initialPoint(row, col) == Approx(0.0).margin(1e-5));
|
||||
}
|
||||
@@ -207,8 +207,8 @@ TEST_CASE("LMNNSeparableObjectiveTest", "[LMNNTest]")
|
||||
|
||||
// Result calculated by hand.
|
||||
arma::mat coordinates = arma::eye<arma::mat>(2, 2);
|
||||
REQUIRE(lmnnfn.Evaluate(coordinates, 0, 1) == Approx( 1.576).epsilon(1e-7));
|
||||
REQUIRE(lmnnfn.Evaluate(coordinates, 1, 1) == Approx( 1.576).epsilon(1e-7));
|
||||
REQUIRE(lmnnfn.Evaluate(coordinates, 0, 1) == Approx(1.576).epsilon(1e-7));
|
||||
REQUIRE(lmnnfn.Evaluate(coordinates, 1, 1) == Approx(1.576).epsilon(1e-7));
|
||||
REQUIRE(lmnnfn.Evaluate(coordinates, 2, 1) == Approx(1.576).epsilon(1e-7));
|
||||
REQUIRE(lmnnfn.Evaluate(coordinates, 3, 1) == Approx(1.576).epsilon(1e-7));
|
||||
REQUIRE(lmnnfn.Evaluate(coordinates, 4, 1) == Approx(1.576).epsilon(1e-7));
|
||||
@@ -326,21 +326,21 @@ TEST_CASE("LMNNSeparableEvaluateWithGradientTest", "[LMNNTest]")
|
||||
|
||||
objective = lmnnfn.EvaluateWithGradient(coordinates, 4, gradient, 1);
|
||||
|
||||
REQUIRE(objective == Approx( 1.576).epsilon(1e-7));
|
||||
REQUIRE(objective == Approx(1.576).epsilon(1e-7));
|
||||
|
||||
REQUIRE(gradient(0, 0) == Approx( -0.048).epsilon(1e-7));
|
||||
REQUIRE(gradient(0, 1) == Approx( 0.0).epsilon(1e-7));
|
||||
REQUIRE(gradient(1, 0) == Approx( 0.0).epsilon(1e-7));
|
||||
REQUIRE(gradient(1, 1) == Approx( 2.0).epsilon(1e-7));
|
||||
REQUIRE(gradient(0, 0) == Approx(-0.048).epsilon(1e-7));
|
||||
REQUIRE(gradient(0, 1) == Approx(0.0).epsilon(1e-7));
|
||||
REQUIRE(gradient(1, 0) == Approx(0.0).epsilon(1e-7));
|
||||
REQUIRE(gradient(1, 1) == Approx(2.0).epsilon(1e-7));
|
||||
|
||||
objective = lmnnfn.EvaluateWithGradient(coordinates, 5, gradient, 1);
|
||||
|
||||
REQUIRE(objective == Approx( 1.576).epsilon(1e-7));
|
||||
REQUIRE(objective == Approx(1.576).epsilon(1e-7));
|
||||
|
||||
REQUIRE(gradient(0, 0) == Approx( -0.048).epsilon(1e-7));
|
||||
REQUIRE(gradient(0, 1) == Approx( 0.0).epsilon(1e-7));
|
||||
REQUIRE(gradient(1, 0) == Approx( 0.0).epsilon(1e-7));
|
||||
REQUIRE(gradient(1, 1) == Approx( 2.0).epsilon(1e-7));
|
||||
REQUIRE(gradient(0, 0) == Approx(-0.048).epsilon(1e-7));
|
||||
REQUIRE(gradient(0, 1) == Approx(0.0).epsilon(1e-7));
|
||||
REQUIRE(gradient(1, 0) == Approx(0.0).epsilon(1e-7));
|
||||
REQUIRE(gradient(1, 1) == Approx(2.0).epsilon(1e-7));
|
||||
}
|
||||
|
||||
// Check that final objective value using SGD optimizer is optimal.
|
||||
@@ -450,7 +450,7 @@ TEST_CASE("LMNNAccuracyTest", "[LMNNTest]")
|
||||
REQUIRE(initAccuracy < finalAccuracy);
|
||||
|
||||
// Since this is a very simple dataset final accuracy should be around 100%.
|
||||
REQUIRE(finalAccuracy == Approx( 100.0).epsilon(1e-7));
|
||||
REQUIRE(finalAccuracy == Approx(100.0).epsilon(1e-7));
|
||||
}
|
||||
|
||||
// Check that accuracy while learning square distance matrix is the same as when
|
||||
|
||||
@@ -201,7 +201,7 @@ TEST_CASE("KLDivergenceMeanTest", "[LossFunctionsTest]")
|
||||
target = arma::exp(arma::mat("2 1 1 1 1 1 1 1 1 1"));
|
||||
|
||||
loss = module.Forward(input, target);
|
||||
REQUIRE(loss == Approx(-1.1 ).epsilon(1e-5));
|
||||
REQUIRE(loss == Approx(-1.1).epsilon(1e-5));
|
||||
|
||||
// Test the Backward function.
|
||||
module.Backward(input, target, output);
|
||||
@@ -846,7 +846,8 @@ TEST_CASE("SoftMarginLossTest", "[LossFunctionsTest]")
|
||||
|
||||
// Test the Backward function.
|
||||
module1.Backward(input, target, output);
|
||||
REQUIRE(arma::as_scalar(arma::accu(output)) == Approx(-1.48227).epsilon(1e-3));
|
||||
REQUIRE(arma::as_scalar(arma::accu(output)) ==
|
||||
Approx(-1.48227).epsilon(1e-3));
|
||||
REQUIRE(output.n_rows == input.n_rows);
|
||||
REQUIRE(output.n_cols == input.n_cols);
|
||||
CheckMatrices(output, expectedOutput, 0.1);
|
||||
@@ -865,7 +866,8 @@ TEST_CASE("SoftMarginLossTest", "[LossFunctionsTest]")
|
||||
|
||||
// Test the Backward function.
|
||||
module2.Backward(input, target, output);
|
||||
REQUIRE(arma::as_scalar(arma::accu(output)) == Approx(-0.164697).epsilon(1e-3));
|
||||
REQUIRE(arma::as_scalar(arma::accu(output)) ==
|
||||
Approx(-0.164697).epsilon(1e-3));
|
||||
REQUIRE(output.n_rows == input.n_rows);
|
||||
REQUIRE(output.n_cols == input.n_cols);
|
||||
CheckMatrices(output, expectedOutput, 0.1);
|
||||
@@ -884,12 +886,13 @@ TEST_CASE("MeanAbsolutePercentageErrorTest", "[LossFunctionsTest]")
|
||||
|
||||
// Test the Forward function. Loss should be 95.625.
|
||||
// Loss value calculated manually.
|
||||
double loss = module.Forward(input,target);
|
||||
REQUIRE(loss == Approx(95.625).epsilon(1e-1));
|
||||
double loss = module.Forward(input, target);
|
||||
REQUIRE(loss == Approx(95.625).epsilon(1e-1));
|
||||
|
||||
// Test the Backward function.
|
||||
module.Backward(input, target, output);
|
||||
REQUIRE(arma::as_scalar(arma::accu(output)) == Approx(-105.625).epsilon(1e-3));
|
||||
REQUIRE(arma::as_scalar(arma::accu(output)) ==
|
||||
Approx(-105.625).epsilon(1e-3));
|
||||
REQUIRE(output.n_rows == input.n_rows);
|
||||
REQUIRE(output.n_cols == input.n_cols);
|
||||
CheckMatrices(output, expectedOutput, 0.1);
|
||||
|
||||
@@ -87,7 +87,7 @@ TEST_CASE_METHOD(KDETestFixture, "KDEGaussianRTreeResultsMain",
|
||||
|
||||
// Check whether results are equal.
|
||||
for (size_t i = 0; i < query.n_cols; ++i)
|
||||
REQUIRE(kdeEstimations[i] == Approx( mainEstimations[i]).epsilon(relError));
|
||||
REQUIRE(kdeEstimations[i] == Approx(mainEstimations[i]).epsilon(relError));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ TEST_CASE_METHOD(KDETestFixture, "KDETriangularBallTreeResultsMain",
|
||||
|
||||
// Check whether results are equal.
|
||||
for (size_t i = 0; i < query.n_cols; ++i)
|
||||
REQUIRE(kdeEstimations[i] == Approx( mainEstimations[i]).epsilon(relError));
|
||||
REQUIRE(kdeEstimations[i] == Approx(mainEstimations[i]).epsilon(relError));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,7 +170,7 @@ TEST_CASE_METHOD(KDETestFixture, "KDEMonoResultsMain",
|
||||
|
||||
// Check whether results are equal.
|
||||
for (size_t i = 0; i < reference.n_cols; ++i)
|
||||
REQUIRE(kdeEstimations[i] == Approx( mainEstimations[i]).epsilon(relError));
|
||||
REQUIRE(kdeEstimations[i] == Approx(mainEstimations[i]).epsilon(relError));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,7 +239,7 @@ TEST_CASE_METHOD(KDETestFixture, "KDEModelReuse",
|
||||
|
||||
// Check estimations are the same.
|
||||
for (size_t i = 0; i < samples; ++i)
|
||||
REQUIRE(oldEstimations[i] == Approx( newEstimations[i]).epsilon(relError));
|
||||
REQUIRE(oldEstimations[i] == Approx(newEstimations[i]).epsilon(relError));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,7 +282,7 @@ TEST_CASE_METHOD(KDETestFixture, "KDEGaussianSingleKDTreeResultsMain",
|
||||
|
||||
// Check whether results are equal.
|
||||
for (size_t i = 0; i < query.n_cols; ++i)
|
||||
REQUIRE(kdeEstimations[i] == Approx( mainEstimations[i]).epsilon(relError));
|
||||
REQUIRE(kdeEstimations[i] == Approx(mainEstimations[i]).epsilon(relError));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -453,7 +453,8 @@ TEST_CASE_METHOD(KRANNTestFixture, "KRANNDifferentTreeType",
|
||||
|
||||
// Check that initial output matrices and the output matrices using
|
||||
// saved model are equal
|
||||
CHECK(output_model->TreeType() == 0);
|
||||
const bool check = output_model->TreeType() == 0;
|
||||
CHECK(check == true);
|
||||
CHECK(IO::GetParam<RANNModel*>("output_model")->TreeType() ==
|
||||
8);
|
||||
delete output_model;
|
||||
@@ -491,7 +492,8 @@ TEST_CASE_METHOD(KRANNTestFixture, "KRANNDifferentSingleSampleLimit",
|
||||
|
||||
// Check that initial output matrices and the output matrices using
|
||||
// saved model are equal.
|
||||
CHECK( IO::GetParam<RANNModel*>("output_model")->SingleSampleLimit() == (int) 15);
|
||||
CHECK(IO::GetParam<RANNModel*>("output_model")->SingleSampleLimit() ==
|
||||
(int) 15);
|
||||
CHECK(output_model->SingleSampleLimit() == (int) 20);
|
||||
delete output_model;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,6 @@ TEST_CASE("NaiveBayesClassifierTest", "[NBCTest]")
|
||||
{
|
||||
for (size_t j = 0; j < testResProbs.n_rows; ++j)
|
||||
{
|
||||
|
||||
REQUIRE(testResProbs(j, i) + 0.0001 ==
|
||||
Approx(calcProbs(j, i) + 0.0001).epsilon(0.0001));
|
||||
}
|
||||
|
||||
@@ -316,7 +316,8 @@ TEST_CASE("PCAScalingTest", "[PCATest]")
|
||||
// zero. There is noise, of course...
|
||||
REQUIRE(std::abs(eigvec(0, 0)) == Approx(sqrt(2) / 2).epsilon(0.0035));
|
||||
REQUIRE(std::abs(eigvec(1, 0)) == Approx(sqrt(2) / 2).epsilon(0.0035));
|
||||
REQUIRE(eigvec(2, 0) == Approx(0.0).margin(0.1)); // Large tolerance for noise.
|
||||
// Large tolerance for noise.
|
||||
REQUIRE(eigvec(2, 0) == Approx(0.0).margin(0.1));
|
||||
|
||||
// The second component should be focused almost entirely in the third
|
||||
// dimension.
|
||||
@@ -328,7 +329,8 @@ TEST_CASE("PCAScalingTest", "[PCATest]")
|
||||
// the first (plus tolerance).
|
||||
REQUIRE(std::abs(eigvec(0, 0)) == Approx(sqrt(2) / 2).epsilon(0.0035));
|
||||
REQUIRE(std::abs(eigvec(1, 0)) == Approx(sqrt(2) / 2).epsilon(0.0035));
|
||||
REQUIRE(eigvec(2, 0) == Approx(0.0).margin(0.1)); // Large tolerance for noise.
|
||||
// Large tolerance for noise.
|
||||
REQUIRE(eigvec(2, 0) == Approx(0.0).margin(0.1));
|
||||
|
||||
// The eigenvalues should sum to three.
|
||||
REQUIRE(accu(eigval) == Approx(3.0).epsilon(0.001));
|
||||
|
||||
@@ -206,13 +206,20 @@ TEST_CASE("ExhaustiveSyntheticTest", "[RangeSearchTest]")
|
||||
// Neighbors of point 10.
|
||||
REQUIRE(sortedOutput[newFromOld[10]].size() == 4);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][0].second == newFromOld[9]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][0].first == Approx(0.10).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][1].second == newFromOld[3]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][1].first == Approx(0.25).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][2].second == newFromOld[8]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][2].first == Approx(0.55).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][3].second == newFromOld[1]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][3].first == Approx(0.65).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][0].first ==
|
||||
Approx(0.10).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][1].second ==
|
||||
newFromOld[3]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][1].first ==
|
||||
Approx(0.25).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][2].second ==
|
||||
newFromOld[8]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][2].first ==
|
||||
Approx(0.55).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][3].second ==
|
||||
newFromOld[1]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][3].first ==
|
||||
Approx(0.65).epsilon(1e-7));
|
||||
|
||||
// Now do it again with a different range: [sqrt(0.5) 1.0].
|
||||
if (rs->ReferenceTree())
|
||||
@@ -273,9 +280,11 @@ TEST_CASE("ExhaustiveSyntheticTest", "[RangeSearchTest]")
|
||||
// Neighbors of point 10.
|
||||
REQUIRE(sortedOutput[newFromOld[10]].size() == 2);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][0].second == newFromOld[2]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][0].first == Approx(0.85).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][0].first ==
|
||||
Approx(0.85).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][1].second == newFromOld[0]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][1].first == Approx(0.95).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][1].first ==
|
||||
Approx(0.95).epsilon(1e-7));
|
||||
|
||||
// Now do it again with a different range: [1.0 inf].
|
||||
if (rs->ReferenceTree())
|
||||
@@ -433,13 +442,20 @@ TEST_CASE("ExhaustiveSyntheticTest", "[RangeSearchTest]")
|
||||
// Neighbors of point 10.
|
||||
REQUIRE(sortedOutput[newFromOld[10]].size() == 4);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][0].second == newFromOld[5]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][0].first == Approx(1.22).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][1].second == newFromOld[7]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][1].first == Approx(2.30).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][2].second == newFromOld[6]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][2].first == Approx(3.00).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][3].second == newFromOld[4]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][3].first == Approx(4.05).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][0].first ==
|
||||
Approx(1.22).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][1].second ==
|
||||
newFromOld[7]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][1].first ==
|
||||
Approx(2.30).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][2].second ==
|
||||
newFromOld[6]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][2].first ==
|
||||
Approx(3.00).epsilon(1e-7));
|
||||
REQUIRE(sortedOutput[newFromOld[10]][3].second ==
|
||||
newFromOld[4]);
|
||||
REQUIRE(sortedOutput[newFromOld[10]][3].first ==
|
||||
Approx(4.05).epsilon(1e-7));
|
||||
|
||||
// Clean the memory.
|
||||
delete rs;
|
||||
@@ -1042,7 +1058,7 @@ TEST_CASE("DualBallTreeTest2", "[RangeSearchTest]")
|
||||
{
|
||||
REQUIRE(kdSorted[i][j].second == ballSorted[i][j].second);
|
||||
REQUIRE(kdSorted[i][j].first ==
|
||||
Approx(ballSorted[i][j].first).epsilon (1e-7));
|
||||
Approx(ballSorted[i][j].first).epsilon(1e-7));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ TEST_CASE("DoublePoleCartTest", "[RLComponentsTest]")
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a ContinuousDoublePoleCart instance and check if the main
|
||||
* Constructs a ContinuousDoublePoleCart instance and check if the main
|
||||
* routine works as it should be.
|
||||
*/
|
||||
TEST_CASE("ContinuousDoublePoleCartTest", "[RLComponentsTest]")
|
||||
@@ -285,5 +285,4 @@ TEST_CASE("GreedyPolicyTest", "[RLComponentsTest]")
|
||||
CartPole::Action action = policy.Sample(actionValue);
|
||||
REQUIRE(actionValue[action.action] ==
|
||||
Approx(actionValue.max()).epsilon(1e-7));
|
||||
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ TEST_CASE("NnsNodeToNodeDistance", "[SortPolicyTest]")
|
||||
utility[0] = 0.5;
|
||||
nodeTwo.Bound() |= utility;
|
||||
|
||||
REQUIRE(NearestNeighborSort::BestNodeToNodeDistance(&nodeOne, &nodeTwo) ==
|
||||
REQUIRE(NearestNeighborSort::BestNodeToNodeDistance(&nodeOne, &nodeTwo) ==
|
||||
Approx(0.0).margin(1e-5));
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ TEST_CASE("NnsPointToNodeDistance", "[SortPolicyTest]")
|
||||
// And now when the point is inside the bound.
|
||||
point[0] = 0.5;
|
||||
|
||||
REQUIRE(NearestNeighborSort::BestPointToNodeDistance(point, &node) ==
|
||||
REQUIRE(NearestNeighborSort::BestPointToNodeDistance(point, &node) ==
|
||||
Approx(0.0).margin(1e-5));
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +269,8 @@ TEST_CASE("DictionaryEncodingIndividualCharactersTest", "[StringEncodingTest]")
|
||||
* Test the one pass modification of the dictionary encoding algorithm
|
||||
* in case of individual character encoding.
|
||||
*/
|
||||
TEST_CASE("OnePassDictionaryEncodingIndividualCharactersTest", "[StringEncodingTest]")
|
||||
TEST_CASE("OnePassDictionaryEncodingIndividualCharactersTest",
|
||||
"[StringEncodingTest]")
|
||||
{
|
||||
std::vector<string> input = {
|
||||
"GACCA",
|
||||
@@ -542,7 +543,7 @@ TEST_CASE("CharExtractDictionaryEncodingSerialization", "[StringEncodingTest]")
|
||||
|
||||
/**
|
||||
* Test the Bag of Words encoding algorithm.
|
||||
*/
|
||||
*/
|
||||
TEST_CASE("BagOfWordsEncodingTest", "[StringEncodingTest]")
|
||||
{
|
||||
using DictionaryType = StringEncodingDictionary<boost::string_view>;
|
||||
@@ -617,7 +618,7 @@ TEST_CASE("BagOfWordsEncodingTest", "[StringEncodingTest]")
|
||||
|
||||
/**
|
||||
* Test the Bag of Words encoding algorithm. The output is saved into a vector.
|
||||
*/
|
||||
*/
|
||||
TEST_CASE("VectorBagOfWordsEncodingTest", "[StringEncodingTest]")
|
||||
{
|
||||
using DictionaryType = StringEncodingDictionary<boost::string_view>;
|
||||
@@ -684,7 +685,8 @@ TEST_CASE("BagOfWordsEncodingIndividualCharactersTest", "[StringEncodingTest]")
|
||||
* Test the Bag of Words encoding algorithm in case of individual
|
||||
* characters encoding. The output type is vector<vector<size_t>>.
|
||||
*/
|
||||
TEST_CASE("VectorBagOfWordsEncodingIndividualCharactersTest", "[StringEncodingTest]")
|
||||
TEST_CASE("VectorBagOfWordsEncodingIndividualCharactersTest",
|
||||
"[StringEncodingTest]")
|
||||
{
|
||||
std::vector<string> input = {
|
||||
"GACCA",
|
||||
@@ -861,7 +863,8 @@ TEST_CASE("VectorRawCountSmoothIdfEncodingTest", "[StringEncodingTest]")
|
||||
* raw count term frequency type and the smooth inverse document frequency type.
|
||||
* These parameters are the default ones.
|
||||
*/
|
||||
TEST_CASE("RawCountSmoothIdfEncodingIndividualCharactersTest", "[StringEncodingTest]")
|
||||
TEST_CASE("RawCountSmoothIdfEncodingIndividualCharactersTest",
|
||||
"[StringEncodingTest]")
|
||||
{
|
||||
vector<string> input = {
|
||||
"GACCA",
|
||||
@@ -942,7 +945,8 @@ TEST_CASE("RawCountSmoothIdfEncodingIndividualCharactersTest", "[StringEncodingT
|
||||
* These parameters are the default ones. The output type is
|
||||
* vector<vector<double>>.
|
||||
*/
|
||||
TEST_CASE("VectorRawCountSmoothIdfEncodingIndividualCharactersTest", "[StringEncodingTest]")
|
||||
TEST_CASE("VectorRawCountSmoothIdfEncodingIndividualCharactersTest",
|
||||
"[StringEncodingTest]")
|
||||
{
|
||||
std::vector<string> input = {
|
||||
"GACCA",
|
||||
@@ -1068,7 +1072,8 @@ TEST_CASE("VectorTfIdfRawCountEncodingTest", "[StringEncodingTest]")
|
||||
* raw count term frequency type and the non-smooth inverse document frequency
|
||||
* type.
|
||||
*/
|
||||
TEST_CASE("RawCountTfIdfEncodingIndividualCharactersTest", "[StringEncodingTest]")
|
||||
TEST_CASE("RawCountTfIdfEncodingIndividualCharactersTest",
|
||||
"[StringEncodingTest]")
|
||||
{
|
||||
vector<string> input = {
|
||||
"GACCA",
|
||||
@@ -1099,7 +1104,8 @@ TEST_CASE("RawCountTfIdfEncodingIndividualCharactersTest", "[StringEncodingTest]
|
||||
* raw count term frequency type and the non-smooth inverse document frequency
|
||||
* type. The output type is vector<vector<double>>.
|
||||
*/
|
||||
TEST_CASE("VectorRawCountTfIdfEncodingIndividualCharactersTest", "[StringEncodingTest]")
|
||||
TEST_CASE("VectorRawCountTfIdfEncodingIndividualCharactersTest",
|
||||
"[StringEncodingTest]")
|
||||
{
|
||||
std::vector<string> input = {
|
||||
"GACCA",
|
||||
@@ -1129,7 +1135,8 @@ TEST_CASE("VectorRawCountTfIdfEncodingIndividualCharactersTest", "[StringEncodin
|
||||
* Test the Tf-Idf encoding algorithm for individual characters with the
|
||||
* binary term frequency type and the smooth inverse document frequency type.
|
||||
*/
|
||||
TEST_CASE("BinarySmoothIdfEncodingIndividualCharactersTest", "[StringEncodingTest]")
|
||||
TEST_CASE("BinarySmoothIdfEncodingIndividualCharactersTest",
|
||||
"[StringEncodingTest]")
|
||||
{
|
||||
vector<string> input = {
|
||||
"GACCA",
|
||||
@@ -1160,7 +1167,8 @@ TEST_CASE("BinarySmoothIdfEncodingIndividualCharactersTest", "[StringEncodingTes
|
||||
* binary term frequency type and the smooth inverse document frequency type.
|
||||
* The output type is vector<vector<double>>.
|
||||
*/
|
||||
TEST_CASE("VectorBinarySmoothIdfEncodingIndividualCharactersTest", "[StringEncodingTest]")
|
||||
TEST_CASE("VectorBinarySmoothIdfEncodingIndividualCharactersTest",
|
||||
"[StringEncodingTest]")
|
||||
{
|
||||
std::vector<string> input = {
|
||||
"GACCA",
|
||||
@@ -1222,7 +1230,8 @@ TEST_CASE("BinaryTfIdfEncodingIndividualCharactersTest", "[StringEncodingTest]")
|
||||
* sublinear term frequency type and the smooth inverse document frequency
|
||||
* type.
|
||||
*/
|
||||
TEST_CASE("SublinearSmoothIdfEncodingIndividualCharactersTest", "[StringEncodingTest]")
|
||||
TEST_CASE("SublinearSmoothIdfEncodingIndividualCharactersTest",
|
||||
"[StringEncodingTest]")
|
||||
{
|
||||
vector<string> input = {
|
||||
"GACCA",
|
||||
@@ -1254,7 +1263,8 @@ TEST_CASE("SublinearSmoothIdfEncodingIndividualCharactersTest", "[StringEncoding
|
||||
* sublinear term frequency type and the non-smooth inverse document frequency
|
||||
* type.
|
||||
*/
|
||||
TEST_CASE("SublinearTfIdfEncodingIndividualCharactersTest", "[StringEncodingTest]")
|
||||
TEST_CASE("SublinearTfIdfEncodingIndividualCharactersTest",
|
||||
"[StringEncodingTest]")
|
||||
{
|
||||
vector<string> input = {
|
||||
"GACCA",
|
||||
@@ -1286,7 +1296,8 @@ TEST_CASE("SublinearTfIdfEncodingIndividualCharactersTest", "[StringEncodingTest
|
||||
* standard term frequency type and the smooth inverse document frequency
|
||||
* type.
|
||||
*/
|
||||
TEST_CASE("TermFrequencySmoothIdfEncodingIndividualCharactersTest", "[StringEncodingTest]")
|
||||
TEST_CASE("TermFrequencySmoothIdfEncodingIndividualCharactersTest",
|
||||
"[StringEncodingTest]")
|
||||
{
|
||||
vector<string> input = {
|
||||
"GACCA",
|
||||
@@ -1367,7 +1378,8 @@ TEST_CASE("TermFrequencySmoothIdfEncodingIndividualCharactersTest", "[StringEnco
|
||||
* standard term frequency type and the non-smooth inverse document frequency
|
||||
* type.
|
||||
*/
|
||||
TEST_CASE("TermFrequencyTfIdfEncodingIndividualCharactersTest", "[StringEncodingTest]")
|
||||
TEST_CASE("TermFrequencyTfIdfEncodingIndividualCharactersTest",
|
||||
"[StringEncodingTest]")
|
||||
{
|
||||
vector<string> input = {
|
||||
"GACCA",
|
||||
|
||||
Reference in New Issue
Block a user