From dc141e7b117477cb3bbffcc2cba0fd435d4da532 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Thu, 11 Jan 2018 16:57:20 -0500 Subject: [PATCH] Fix minor issues and clean up ShuffleData(). --- src/mlpack/core/math/shuffle_data.hpp | 7 ++----- src/mlpack/tests/recurrent_network_test.cpp | 2 -- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/mlpack/core/math/shuffle_data.hpp b/src/mlpack/core/math/shuffle_data.hpp index e5ba57f114..201576da48 100644 --- a/src/mlpack/core/math/shuffle_data.hpp +++ b/src/mlpack/core/math/shuffle_data.hpp @@ -53,7 +53,6 @@ void ShuffleData(const MatType& inputPoints, // Generate ordering. arma::uvec ordering = arma::shuffle(arma::linspace(0, inputPoints.n_cols - 1, inputPoints.n_cols)); -// std::cout << "ordering:\n" << ordering.t(); // Extract coordinate list representation. arma::umat locations(2, inputPoints.n_nonzero); @@ -75,8 +74,7 @@ void ShuffleData(const MatType& inputPoints, MatType newOutputPoints(locations, values, inputPoints.n_rows, inputPoints.n_cols, true); LabelsType newOutputLabels(inputLabels.n_elem); - for (size_t i = 0; i < inputLabels.n_elem; ++i) - newOutputLabels[ordering[i]] = inputLabels[i]; + newOutputLabels.cols(ordering) = inputLabels; outputPoints = std::move(newOutputPoints); outputLabels = std::move(newOutputLabels); @@ -86,8 +84,7 @@ void ShuffleData(const MatType& inputPoints, outputPoints = MatType(locations, values, inputPoints.n_rows, inputPoints.n_cols, true); outputLabels.set_size(inputLabels.n_elem); - for (size_t i = 0; i < inputLabels.n_elem; ++i) - outputLabels[ordering[i]] = inputLabels[i]; + outputLabels.cols(ordering) = inputLabels; } } diff --git a/src/mlpack/tests/recurrent_network_test.cpp b/src/mlpack/tests/recurrent_network_test.cpp index 5712fb27a6..4a9d747ece 100644 --- a/src/mlpack/tests/recurrent_network_test.cpp +++ b/src/mlpack/tests/recurrent_network_test.cpp @@ -710,8 +710,6 @@ void DistractedSequenceRecallTestNetwork( output.slice(j) = outputSlice; } -// std::cout << "label:\n" << label << "\noutput:" << output - arma::cube label(testLabels.at(0, i).memptr(), outputSize, 1, testLabels.at(0, i).n_elem / outputSize, false, true); if (arma::accu(arma::abs(label - output)) != 0)