[mlpack-git] master: Replace unsupported array operation with arma::vec (a63ddcd)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Wed May 20 11:13:31 EDT 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/322deab1ff056e33d4e6aea5f4d0ef9a5b62ab4c...77d750c8fd46140b1d6060424f68768a21c89377
>---------------------------------------------------------------
commit a63ddcdd77182244e19d9f11bcb0f6b43e403c32
Author: Janzen Brewer <jahabrewer at gmail.com>
Date: Fri May 15 22:44:25 2015 +0000
Replace unsupported array operation with arma::vec
Dynamic length arrays are a g++ extension and their initialization is
only supported from g++-4.9.
>---------------------------------------------------------------
a63ddcdd77182244e19d9f11bcb0f6b43e403c32
src/mlpack/methods/det/dt_utils.cpp | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/mlpack/methods/det/dt_utils.cpp b/src/mlpack/methods/det/dt_utils.cpp
index f46714d..a976415 100644
--- a/src/mlpack/methods/det/dt_utils.cpp
+++ b/src/mlpack/methods/det/dt_utils.cpp
@@ -171,7 +171,8 @@ DTree* mlpack::det::Trainer(arma::mat& dataset,
arma::mat cvData(dataset);
size_t testSize = dataset.n_cols / folds;
- double regularizationConstants[prunedSequence.size()] = {0};
+ arma::vec regularizationConstants(prunedSequence.size());
+ regularizationConstants.fill(0.0);
Timer::Start("cross_validation");
// Go through each fold.
@@ -215,6 +216,8 @@ DTree* mlpack::det::Trainer(arma::mat& dataset,
// Sequentially prune with all the values of available alphas and adding
// values for test values. Don't enter this loop if there are less than two
// trees in the pruned sequence.
+ arma::vec cvRegularizationConstants(prunedSequence.size());
+ cvRegularizationConstants.fill(0.0);
for (size_t i = 0;
i < ((prunedSequence.size() < 2) ? 0 : prunedSequence.size() - 2); ++i)
{
@@ -227,8 +230,7 @@ DTree* mlpack::det::Trainer(arma::mat& dataset,
}
// Update the cv regularization constant.
- #pragma omp atomic
- regularizationConstants[i] += 2.0 * cvVal / (double) dataset.n_cols;
+ cvRegularizationConstants[i] += 2.0 * cvVal / (double) dataset.n_cols;
// Determine the new alpha value and prune accordingly.
double cvOldAlpha = 0.5 * (prunedSequence[i + 1].first +
@@ -245,9 +247,11 @@ DTree* mlpack::det::Trainer(arma::mat& dataset,
}
if (prunedSequence.size() > 2)
- #pragma omp atomic
- regularizationConstants[prunedSequence.size() - 2] += 2.0 * cvVal /
+ cvRegularizationConstants[prunedSequence.size() - 2] += 2.0 * cvVal /
(double) dataset.n_cols;
+
+ #pragma omp critical
+ regularizationConstants += cvRegularizationConstants;
}
Timer::Stop("cross_validation");
More information about the mlpack-git
mailing list