diff --git a/src/mlpack/methods/adaboost/adaboost_impl.hpp b/src/mlpack/methods/adaboost/adaboost_impl.hpp index 7d88c807af..af767d161f 100644 --- a/src/mlpack/methods/adaboost/adaboost_impl.hpp +++ b/src/mlpack/methods/adaboost/adaboost_impl.hpp @@ -27,6 +27,7 @@ #define MLPACK_METHODS_ADABOOST_ADABOOST_IMPL_HPP #include "adaboost.hpp" +#include namespace mlpack { namespace adaboost { @@ -71,6 +72,9 @@ double AdaBoost::Train( const size_t iterations, const double tolerance) { + // Sanity check on data + util::CheckSameDimensionality(data, labels, "Adaboost::Train()"); + // Clear information from previous runs. wl.clear(); alpha.clear(); @@ -242,7 +246,10 @@ void AdaBoost::Classify( const MatType& test, arma::Row& predictedLabels, arma::mat& probabilities) -{ +{ + // Sanity Check on Data + util::CheckSameDimensionality(test, predictedLabels, "Adaboost::Classify()"); + arma::Row tempPredictedLabels(test.n_cols); probabilities.zeros(numClasses, test.n_cols); diff --git a/src/mlpack/methods/matrix_completion/matrix_completion.cpp b/src/mlpack/methods/matrix_completion/matrix_completion.cpp index 6210b69453..6a2b9db523 100644 --- a/src/mlpack/methods/matrix_completion/matrix_completion.cpp +++ b/src/mlpack/methods/matrix_completion/matrix_completion.cpp @@ -11,6 +11,7 @@ */ #include "matrix_completion.hpp" +#include namespace mlpack { namespace matrix_completion { @@ -59,13 +60,7 @@ void MatrixCompletion::CheckValues() << "indices does not have 2 rows!" << std::endl; } - if (indices.n_cols != values.n_elem) - { - Log::Fatal << "MatrixCompletion::CheckValues(): the number of constraint " - << "indices (columns of constraint indices matrix) does not match the " - << "number of constraint values (length of constraint value vector)!" - << std::endl; - } + util::CheckSameSizes(values, indices, "MatrixCompletion::CheckValues()", "indices"); for (size_t i = 0; i < values.n_elem; ++i) {