diff --git a/src/mlpack/core/math/lin_alg_impl.hpp b/src/mlpack/core/math/lin_alg_impl.hpp index 7e0d1252e9..76ba56b861 100644 --- a/src/mlpack/core/math/lin_alg_impl.hpp +++ b/src/mlpack/core/math/lin_alg_impl.hpp @@ -89,8 +89,6 @@ inline void WhitenUsingSVD(const arma::mat& x, */ inline void RandVector(arma::vec& v) { - v.zeros(); - for (size_t i = 0; i + 1 < v.n_elem; i += 2) { double a = math::Random(); diff --git a/src/mlpack/methods/det/dtree_impl.hpp b/src/mlpack/methods/det/dtree_impl.hpp index 92b1803408..016bf2df79 100644 --- a/src/mlpack/methods/det/dtree_impl.hpp +++ b/src/mlpack/methods/det/dtree_impl.hpp @@ -93,7 +93,7 @@ void ExtractSplits(std::vector>& splitVec, const size_t minLeafSize) { // It's common sense, but we also use it in a check later. - mlpack::Log::Assert(minLeafSize > 0); + Log::Assert(minLeafSize > 0); typedef std::pair SplitItem; const size_t n_elem = end - start; @@ -116,7 +116,7 @@ void ExtractSplits(std::vector>& splitVec, const ElemType newVal = valsVec[i]; if (lastVal < ElemType(0) && newVal > ElemType(0) && zeroes > 0) { - mlpack::Log::Assert(padding == 0); // We should arrive here once! + Log::Assert(padding == 0); // We should arrive here once! // The minLeafSize > 0 also guarantees we're not entering right at the // start. @@ -148,9 +148,8 @@ void ExtractSplits(std::vector>& splitVec, } // namespace details template -mlpack::det::DTree::DTree() : - start(0), - end(0), +DTree::DTree() : + end(0), splitDim(size_t(-1)), splitValue(std::numeric_limits::max()), logNegError(-DBL_MAX), @@ -188,10 +187,8 @@ DTree::DTree(const DTree& obj) : } template -DTree& mlpack::det::DTree::operator=( - const mlpack::det::DTree& obj) -{ - if (this == &obj) +DTree& DTree::operator=( + const DTree::DTree(const StatType& maxVals, { /* Nothing to do. */ } template -mlpack::det::DTree::DTree(MatType & data) : - start(0), - end(data.n_cols), +DTree::DTree(MatType & data) : + end(data.n_cols), maxVals(arma::max(data, 1)), minVals(arma::min(data, 1)), splitDim(size_t(-1)), @@ -443,8 +439,8 @@ bool DTree::FindSplit(const MatType& data, // Ensure the dimensionality of the data is the same as the dimensionality of // the bounding rectangle. - mlpack::Log::Assert(data.n_rows == maxVals.n_elem); - mlpack::Log::Assert(data.n_rows == minVals.n_elem); + Log::Assert(data.n_rows == maxVals.n_elem); + Log::Assert(data.n_rows == minVals.n_elem); const size_t points = end - start; @@ -503,7 +499,7 @@ bool DTree::FindSplit(const MatType& data, { // Ensure that the right node will have at least the minimum number of // points. - mlpack::Log::Assert((points - position) >= minLeafSize); + Log::Assert((points - position) >= minLeafSize); // Now we have to see if the error will be reduced. Simple manipulation // of the error function gives us the condition we must satisfy: @@ -592,8 +588,8 @@ double DTree::Grow(MatType& data, const size_t maxLeafSize, const size_t minLeafSize) { - mlpack::Log::Assert(data.n_rows == maxVals.n_elem); - mlpack::Log::Assert(data.n_rows == minVals.n_elem); + Log::Assert(data.n_rows == maxVals.n_elem); + Log::Assert(data.n_rows == minVals.n_elem); double leftG, rightG; @@ -667,7 +663,7 @@ double DTree::Grow(MatType& data, else { // We can make this a leaf node. - mlpack::Log::Assert((size_t) (end - start) >= minLeafSize); + Log::Assert((size_t) (end - start) >= minLeafSize); subtreeLeaves = 1; subtreeLeavesLogNegError = logNegError; } @@ -821,7 +817,7 @@ double DTree::PruneAndUpdate(const double oldAlpha, gT = alphaUpper - std::log((double) (subtreeLeaves - 1)); } - mlpack::Log::Assert(gT < std::numeric_limits::max()); + Log::Assert(gT < std::numeric_limits::max()); return std::min((double) gT, std::min(leftG, rightG)); } @@ -863,7 +859,7 @@ bool DTree::WithinRange(const VecType& query) const template double DTree::ComputeValue(const VecType& query) const { - mlpack::Log::Assert(query.n_elem == maxVals.n_elem); + Log::Assert(query.n_elem == maxVals.n_elem); if (root == 1) // If we are the root... { @@ -908,7 +904,7 @@ TagType DTree::TagTree(const TagType& tag, bool every) template TagType DTree::FindBucket(const VecType& query) const { - mlpack::Log::Assert(query.n_elem == maxVals.n_elem); + Log::Assert(query.n_elem == maxVals.n_elem); if (root == 1) // If we are the root... { @@ -985,8 +981,8 @@ void DTree::FillMinMax(const StatType& mins, template template -void mlpack::det::DTree::serialize(Archive& ar, - const uint32_t /* version */) +void DTree::serialize(Archive& ar, + const uint32_t /* version */) { ar(CEREAL_NVP(start)); ar(CEREAL_NVP(end)); diff --git a/src/mlpack/methods/reinforcement_learning/q_networks/categorical_dqn.hpp b/src/mlpack/methods/reinforcement_learning/q_networks/categorical_dqn.hpp index 917636d87b..ba5c1f7abb 100644 --- a/src/mlpack/methods/reinforcement_learning/q_networks/categorical_dqn.hpp +++ b/src/mlpack/methods/reinforcement_learning/q_networks/categorical_dqn.hpp @@ -81,21 +81,21 @@ class CategoricalDQN vMax(config.VMax()), isNoisy(isNoisy) { - network.Add(new mlpack::ann::Linear<>(inputDim, h1)); - network.Add(new mlpack::ann::ReLULayer<>()); + network.Add(new ann::Linear<>(inputDim, h1)); + network.Add(new ann::ReLULayer<>()); if (isNoisy) { noisyLayerIndex.push_back(network.Model().size()); - network.Add(new mlpack::ann::NoisyLinear<>(h1, h2)); - network.Add(new mlpack::ann::ReLULayer<>()); + network.Add(new ann::NoisyLinear<>(h1, h2)); + network.Add(new ann::ReLULayer<>()); noisyLayerIndex.push_back(network.Model().size()); - network.Add(new mlpack::ann::NoisyLinear<>(h2, outputDim * atomSize)); + network.Add(new ann::NoisyLinear<>(h2, outputDim * atomSize)); } else { - network.Add(new mlpack::ann::Linear<>(h1, h2)); - network.Add(new mlpack::ann::ReLULayer<>()); - network.Add(new mlpack::ann::Linear<>(h2, outputDim * atomSize)); + network.Add(new ann::Linear<>(h1, h2)); + network.Add(new ann::ReLULayer<>()); + network.Add(new ann::Linear<>(h2, outputDim * atomSize)); } } @@ -181,7 +181,7 @@ class CategoricalDQN { for (size_t i = 0; i < noisyLayerIndex.size(); ++i) { - boost::get*> + boost::get*> (network.Model()[noisyLayerIndex[i]])->ResetNoise(); } } @@ -234,7 +234,7 @@ class CategoricalDQN std::vector noisyLayerIndex; //! Locally-stored softmax activation function. - mlpack::ann::Softmax<> softMax; + ann::Softmax<> softMax; //! Locally-stored activations from softMax. arma::mat activations;