[mlpack-git] master: Check the feature size. (2dbcd01)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Thu Nov 19 16:17:35 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/319205b2f3103187c584db302b1a3683aa2fbfdf...a1dada8ba0f88f14653f09ea8c3ec8b04d982434
>---------------------------------------------------------------
commit 2dbcd0128b2574dab5e1ba0d0eb1a5368ee9b99f
Author: Ryan Curtin <ryan at ratml.org>
Date: Thu Nov 19 06:47:52 2015 -0800
Check the feature size.
>---------------------------------------------------------------
2dbcd0128b2574dab5e1ba0d0eb1a5368ee9b99f
src/mlpack/methods/softmax_regression/softmax_regression_impl.hpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/mlpack/methods/softmax_regression/softmax_regression_impl.hpp b/src/mlpack/methods/softmax_regression/softmax_regression_impl.hpp
index db4d890..d21b295 100644
--- a/src/mlpack/methods/softmax_regression/softmax_regression_impl.hpp
+++ b/src/mlpack/methods/softmax_regression/softmax_regression_impl.hpp
@@ -60,6 +60,14 @@ template<template<typename> class OptimizerType>
void SoftmaxRegression<OptimizerType>::Predict(const arma::mat& testData,
arma::vec& predictions) const
{
+ if (testData.n_rows != FeatureSize())
+ {
+ std::ostringstream oss;
+ oss << "SoftmaxRegression::Predict(): test data has " << testData.n_rows
+ << " dimensions, but model has " << FeatureSize() << "dimensions";
+ throw std::invalid_argument(oss.str());
+ }
+
// Calculate the probabilities for each test input.
arma::mat hypothesis, probabilities;
if (fitIntercept)
More information about the mlpack-git
mailing list