Add : Size checks for adaboost and matix completion
Signed-off-by: eshaanagarwal <eshaan060202@gmail.com>
This commit is contained in:
committed by
Ryan Curtin
parent
66bc9cbe00
commit
640dd0cde8
@@ -27,6 +27,7 @@
|
||||
#define MLPACK_METHODS_ADABOOST_ADABOOST_IMPL_HPP
|
||||
|
||||
#include "adaboost.hpp"
|
||||
#include <mlpack/core/util/size_checks.hpp>
|
||||
|
||||
namespace mlpack {
|
||||
namespace adaboost {
|
||||
@@ -71,6 +72,9 @@ double AdaBoost<WeakLearnerType, MatType>::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<WeakLearnerType, MatType>::Classify(
|
||||
const MatType& test,
|
||||
arma::Row<size_t>& predictedLabels,
|
||||
arma::mat& probabilities)
|
||||
{
|
||||
{
|
||||
// Sanity Check on Data
|
||||
util::CheckSameDimensionality(test, predictedLabels, "Adaboost::Classify()");
|
||||
|
||||
arma::Row<size_t> tempPredictedLabels(test.n_cols);
|
||||
|
||||
probabilities.zeros(numClasses, test.n_cols);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
#include "matrix_completion.hpp"
|
||||
#include <mlpack/core/util/size_checks.hpp>
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user