This commit is contained in:
jeffin143
2020-11-02 19:16:20 +05:30
39 changed files with 554 additions and 135 deletions
+221
View File
@@ -0,0 +1,221 @@
#!/usr/bin/env bash
#
# Release a new version of mlpack.
#
# Usage: release-mlpack.sh X Y Z
#
# where X is the major version, Y is the minor version, and Z is the patch
# version. Run this from the root of the repository.
#
# Make sure HISTORY.md is updated first!
set +e
if [ "$#" -ne "4" ];
then
echo "Usage: mlpack-release.sh <github username> <major> <minor> <patch>";
exit 1;
fi
# First, check for any unlicensed files.
output=$(
for i in $(find src/ -iname '*.[hc]pp');
do
echo -n $i": ";
cat $i | grep 'mlpack is free software;' | wc -l;
done |\
grep -v ': 1' |\
grep -v 'arma_extend' |\
grep -v 'boost_backport' |\
grep -v 'arma_config.hpp' |\
grep -v 'gitversion.hpp' |\
grep -v 'CLI11.hpp' |\
grep -v 'bindings/R/mlpack/src/boost/serialization' |\
grep -v 'tests/catch.hpp');
lines=`echo $output | grep -v '^[ ]*$' | wc -l`;
if [ "0$lines" -gt "0" ];
then
echo "Unlicensed files found! Aborting release.";
echo "$output";
exit 1;
fi
# Now, check that there are no local changes.
lines=`git diff | wc -l | sed -e 's/^\s*//g'`;
if [ "$lines" != "0" ]; then
echo "git diff returned a nonzero result!";
echo "";
git diff;
exit 1;
fi
# Next, make sure the origin is right.
dest_remote_name=`git remote -v |\
grep "mlpack/mlpack (fetch)" |\
head -1 |\
awk -F' ' '{ print $1 }'`;
if [ "a$dest_remote_name" == "a" ]; then
echo "No git remote found for https://github.com/mlpack/mlpack!";
echo "Make sure that you've got the ensmallen repository as a remote, and" \
"that the master branch from that remote is checked out.";
echo "You can do this with a fresh repository via \`git clone" \
"https://github.com/mlpack/mlpack\`.";
exit 1;
fi
# Also check that we're on the master branch, from the correct origin.
current_branch=`git branch --no-color | grep '^\* ' | awk -F' ' '{ print $2 }'`;
current_origin=`git rev-parse --abbrev-ref --symbolic-full-name @{u} |\
awk -F'/' '{ print $1 }'`;
if [ "a$current_branch" != "amaster" ]; then
echo "Current branch is $current_branch.";
echo "This script has to be run from the master branch.";
exit 1;
elif [ "a$current_origin" != "a$dest_remote_name" ]; then
echo "Current branch does not track from remote mlpack repository!";
echo "Instead, it tracks from $current_origin/master.";
echo "Make sure to check out a branch that tracks $dest_remote_name/master.";
exit 1;
fi
# Make sure `hub` is installed.
hub_output="`which hub`" || true;
if [ "a$hub_output" == "a" ]; then
echo "The Hub command-line tool must be installed for this script to run" \
"successfully.";
echo "See https://hub.github.com for more details and installation" \
"instructions.";
echo "";
echo "(apt-get install hub on Debian and Ubuntu)";
echo "(brew install hub via Homebrew)";
exit 1;
fi
# Check git remotes: we need to make sure we have a fork to push to.
github_user=$1;
remote_name`git remote -v |\
grep "$github_user/mlpack (push)" |\
head -1 |\
awk -F' ' '{ print $1 }'`;
if [ "a$remote_name" == "a" ]; then
echo "No git remote found for $github_user/mlpack!";
echo "Adding remote '$github_user'.";
git remote add $github_user https://github.com/$github_user/mlpack;
remote_name="$github_user";
fi
git fetch $github_user;
# Make sure everything is up to date.
git pull;
# Make updates to files that will be needed for the release.
MAJOR="$2";
MINOR="$3";
PATCH="$4";
# Update version.
sed --in-place -E 's/PROJECT_NUMBER([ \t]*)= .*$/PROJECT_NUMBER\1= '$MAJOR'.'$MINOR'.'$PATCH'/' \
Doxyfile;
sed --in-place 's/MLPACK_VERSION_MAJOR [0-9]*$/MLPACK_VERSION_MAJOR '$MAJOR'/' \
src/mlpack/core/util/version.hpp;
sed --in-place 's/MLPACK_VERSION_MINOR [0-9]*$/MLPACK_VERSION_MINOR '$MINOR'/' \
src/mlpack/core/util/version.hpp;
sed --in-place 's/MLPACK_VERSION_PATCH [0-9]*$/MLPACK_VERSION_PATCH '$PATCH'/' \
src/mlpack/core/util/version.hpp;
sed --in-place 's/ VERSION [0-9]*\.[0-9]*/ VERSION '$MAJOR'.'$MINOR'/' \
src/mlpack/CMakeLists.txt;
sed --in-place 's/mlpack-[0-9]\.[0-9]\.[0-9]/mlpack-'$MAJOR'.'$MINOR'.'$PATCH'/g' \
doc/guide/build.hpp;
sed --in-place 's/mlpack-[0-9]\.[0-9]\.[0-9]/mlpack-'$MAJOR'.'$MINOR'.'$PATCH'/g' \
doc/guide/python_quickstart.hpp;
sed --in-place 's/mlpack-[0-9]\.[0-9]\.[0-9]/mlpack-'$MAJOR'.'$MINOR'.'$PATCH'/g' \
doc/guide/sample_ml_app.hpp;
sed --in-place 's/mlpack-[0-9]\.[0-9]\.[0-9]/mlpack-'$MAJOR'.'$MINOR'.'$PATCH'/g' \
doc/examples/sample-ml-app/sample-ml-app/sample-ml-app.vcxproj;
sed --in-place 's/mlpack-[0-9]\.[0-9]\.[0-9]/mlpack-'$MAJOR'.'$MINOR'.'$PATCH'/g' \
README.md;
sed --in-place 's/([0-9]\.[0-9]\.[0-9])/('$MAJOR'.'$MINOR'.'$PATCH')/g' \
README.md;
sed --in-place 's/mlpack [0-9]\.[0-9]\.[0-9]/mlpack '$MAJOR'.'$MINOR'.'$PATCH'/g' \
README.md;
sed --in-place 's/### mlpack ?[.]?[.]?/### mlpack '$MAJOR'.'$MINOR'.'$PATCH'/g' HISTORY.md;
year=`date +%Y`;
month=`date +%m`;
day=`date +%d`;
sed --in-place 's/###### ????-??-??/###### '$year'-'$month'-'$day'/g' \
HISTORY.md;
# Get the latest release of ensmallen.
git clone https://github.com/mlpack/ensmallen /tmp/ensmallen;
cd /tmp/ensmallen;
ens_ver=`git describe --tags $(git rev-list --tags --max-count=1)`;
echo "Latest version of ensmallen: $ens_ver"
cd -;
sed --in-place "s/ensmallen-latest.tar.gz/ensmallen-$ens_ver.tar.gz/" CMakeLists.txt;
rm -rf /tmp/ensmallen;
# Make these changes on a release branch.
git checkout -b release-$MAJOR.$MINOR.$PATCH;
git add Doxyfile src/mlpack/core/util/version.hpp src/mlpack/CMakeLists.txt \
doc/guide/build.hpp doc/guide/python_quickstart.hpp \
doc/guide/sample_ml_app.hpp \
doc/examples/sample-ml-app/sample-ml-app/sample-ml-app.vcxproj \
CMakeLists.txt \
README.md \
HISTORY.md;
git commit -m "Update and release version $MAJOR.$MINOR.$PATCH.";
changelog_str=`cat HISTORY.md |\
awk '/^### /{f=0} /^### mlpack '"$MAJOR"'.'"$MINOR"'.'"$PATCH"'/{f=1} f{print}' |\
grep -v '^#' |\
tr '\n' '!' |\
sed -e 's/! [ ]*/ /g' |\
tr '!' '\n'`;
echo "Changelog string:"
echo "$changelog_str"
# Update version again and add a new block for HISTORY.md.
sed --in-place 's/MLPACK_VERSION_PATCH [0-9]*$/MLPACK_VERSION_PATCH '$(($PATCH + 1))'/' \
src/mlpack/core/util/version.hpp;
sed --in-place 's/ensmallen-'$ens_ver'.tar.gz/ensmallen-latest.tar.gz/' CMakeLists.txt;
echo "### mlpack ?.?.?" > HISTORY.md.new;
echo "###### ????-??-??" >> HISTORY.md.new;
echo "" >> HISTORY.md.new;
cat HISTORY.md >> HISTORY.md.new;
mv HISTORY.md.new HISTORY.md;
git add HISTORY.md;
git add src/mlpack/core/util/version.hpp CMakeLists.txt;
git commit -m "Add new block for next release to HISTORY.md.";
# Push to new branch.
git push --set-upstream $github_user release-$MAJOR.$MINOR.$PATCH;
# Next, we have to actually open the PR for the release.
hub pull-request \
-b mlpack:master \
-h $github_user:release-$MAJOR.$MINOR.$PATCH \
-m "Release version $MAJOR.$MINOR.$PATCH" \
-m "This automatically-generated pull request adds the commits necessary to
make the $MAJOR.$MINOR.$PATCH release." \
-m "Once the PR is merged, mlpack-bot will tag the release as HEAD~1 (so
that it doesn't include the new HISTORY block) and publish it." \
-m "Or, well, hopefully that will happen someday." \
-m "When you merge this PR, be sure to merge it using a *rebase*." \
-m "### Changelog" \
-m "$changelog_str" \
-l "t: release"
echo "";
echo "Switching back to 'master' branch.";
echo "If you want to access the release branch again, use \`git checkout " \
"release-$MAJOR.$MINOR.$PATCH\`.";
echo 0;
+65
View File
@@ -0,0 +1,65 @@
#!/usr/bin/env bash
#
# This script is used to update the website after an mlpack release is made.
# Push access to the mlpack.org website repository is needed. Generally, this
# script will be run by mlpack-bot, so it never needs to be run by hand.
#
# Usage: update-website-after-release.sh <major> <minor> <patch>
MAJOR=$1;
MINOR=$2;
PATCH=$3;
# Make sure that the mlpack repository exists.
dest_remote_name=`git remote -v |\
grep "mlpack/mlpack (fetch)" |\
head -1 |\
awk -F' ' '{ print $1 }'`;
if [ "a$dest_remote_name" == "a" ]; then
echo "No git remote found for mlpack/mlpack!";
echo "Make sure that you've got the mlpack repository as a remote, and" \
"that the master branch from that remote is checked out.";
echo "You can do this with a fresh repository via \`git clone" \
"https://github.com/mlpack/mlpack\`.";
exit 1;
fi
# Update the checked out repository, so that we can get the tags.
git fetch $dest_remote_name;
# Check out a copy of the ensmallen.org repository.
git clone git@github.com:mlpack/mlpack.org /tmp/mlpack.org/;
# Create the release file.
git archive --prefix=mlpack-$MAJOR.$MINOR.$PATCH/ $MAJOR.$MINOR.$PATCH |\
gzip > /tmp/mlpack.org/files/mlpack-$MAJOR.$MINOR.$PATCH.tar.gz;
# Now update the website.
wd=`pwd`;
cd /tmp/mlpack.org/;
# These may be specific to the old website.
sed --in-place 's/[0-9]\.[0-9]\.[0-9]/'$MAJOR'.'$MINOR'.'$PATCH'/g' index.md;
sed --in-place 's/[0-9]\.[0-9]\.[0-9]/'$MAJOR'.'$MINOR'.'$PATCH'/g' docs.md;
sed --in-place 's/[0-9]\.[0-9]\.[0-9]/'$MAJOR'.'$MINOR'.'$PATCH'/g' getstarted.md;
sed --in-place 's/[0-9]\.[0-9]\.[0-9]/'$MAJOR'.'$MINOR'.'$PATCH'/g' community.md;
git add index.md docs.md getstarted.md community.md;
# These may be specific to the new website.
sed --in-place 's/mlpack-[0-9]\.[0-9]\.[0-9]/mlpack-'$MAJOR'.'$MINOR'.'$PATCH'/g' html/index.html;
sed --in-place 's/Version [0-9]\.[0-9]\.[0-9]/Version '$MAJOR'.'$MINOR'.'$PATCH'/g' html/index.html;
sed --in-place 's/[0-9]\.[0-9]\.[0-9]/'$MAJOR'.'$MINOR'.'$PATCH'/g' html/getstarted.html;
sed --in-place 's/[0-9]\.[0-9]\.[0-9]/'$MAJOR'.'$MINOR'.'$PATCH'/g' html/config/install.md;
git add html/index.html html/getstarted.html html/config/install.md;
git commit -m "Update links to latest stable version.";
git add files/mlpack-$MAJOR.$MINOR.$PATCH.tar.gz;
git commit -m "Release version $MAJOR.$MINOR.$PATCH.";
# Finally, push, and we're done.
git push origin;
cd $wd;
rm -rf /tmp/mlpack.org;
+1 -1
View File
@@ -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;
+2 -2
View File
@@ -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
+8 -7
View File
@@ -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>
+8 -7
View File
@@ -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>
+5 -2
View File
@@ -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;
+1 -1
View File
@@ -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));
+1 -1
View File
@@ -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;
+7 -4
View File
@@ -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;
+2 -2
View File
@@ -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;
+6 -3
View File
@@ -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>
+3 -3
View File
@@ -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));
+14 -3
View File
@@ -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));
}
}
}
/**
+68 -5
View File
@@ -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);
}
+2 -1
View File
@@ -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");
+20 -10
View File
@@ -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));
}
/**
+2 -1
View File
@@ -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();
-1
View File
@@ -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]")
+14 -14
View File
@@ -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
+9 -6
View File
@@ -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);
+5 -5
View File
@@ -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));
}
/**
+4 -2
View File
@@ -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;
}
-1
View File
@@ -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));
}
+4 -2
View File
@@ -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));
+33 -17
View File
@@ -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));
}
}
}
+1 -2
View File
@@ -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));
}
+2 -2
View File
@@ -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));
}
+26 -14
View File
@@ -268,7 +268,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",
@@ -541,7 +542,7 @@ TEST_CASE("CharExtractDictionaryEncodingSerialization", "[StringEncodingTest]")
/**
* Test the Bag of Words encoding algorithm.
*/
*/
TEST_CASE("BagOfWordsEncodingTest", "[StringEncodingTest]")
{
using DictionaryType = StringEncodingDictionary<boost::string_view>;
@@ -616,7 +617,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>;
@@ -683,7 +684,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",
@@ -860,7 +862,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",
@@ -941,7 +944,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",
@@ -1067,7 +1071,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",
@@ -1098,7 +1103,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",
@@ -1128,7 +1134,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",
@@ -1159,7 +1166,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",
@@ -1221,7 +1229,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",
@@ -1253,7 +1262,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",
@@ -1285,7 +1295,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",
@@ -1366,7 +1377,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",