From ffd808332fccbd1a62cdc4a47dca9fc36f3a8958 Mon Sep 17 00:00:00 2001 From: Omar Shrit Date: Sun, 14 Jan 2024 21:01:02 +0100 Subject: [PATCH] Fix style issues after regexp Signed-off-by: Omar Shrit --- .../methods/ann/augmented/tasks/score_impl.hpp | 3 +-- .../methods/ann/dists/normal_distribution_impl.hpp | 6 ++---- src/mlpack/methods/ann/layer/linear3d_impl.hpp | 3 +-- src/mlpack/methods/ann/layer/linear_impl.hpp | 3 +-- src/mlpack/methods/ann/layer/linear_no_bias_impl.hpp | 3 +-- src/mlpack/methods/ann/layer/lstm_impl.hpp | 12 ++++-------- .../ann/loss_functions/mean_squared_error_impl.hpp | 3 +-- .../mean_squared_logarithmic_error_impl.hpp | 3 +-- .../cf/neighbor_search_policies/pearson_search.hpp | 3 +-- 9 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/mlpack/methods/ann/augmented/tasks/score_impl.hpp b/src/mlpack/methods/ann/augmented/tasks/score_impl.hpp index 2efb37a67d..31309e4e25 100644 --- a/src/mlpack/methods/ann/augmented/tasks/score_impl.hpp +++ b/src/mlpack/methods/ann/augmented/tasks/score_impl.hpp @@ -37,8 +37,7 @@ double SequencePrecision(arma::field trueOutputs, for (size_t i = 0; i < testSize; ++i) { - arma::vec delta = vectorise(arma::abs( - trueOutputs.at(i) - predOutputs.at(i))); + arma::vec delta = vectorise(abs(trueOutputs.at(i) - predOutputs.at(i))); double maxDelta = arma::max(delta); if (maxDelta < tol) { diff --git a/src/mlpack/methods/ann/dists/normal_distribution_impl.hpp b/src/mlpack/methods/ann/dists/normal_distribution_impl.hpp index c395c69c6d..5192d8f9b3 100644 --- a/src/mlpack/methods/ann/dists/normal_distribution_impl.hpp +++ b/src/mlpack/methods/ann/dists/normal_distribution_impl.hpp @@ -45,8 +45,7 @@ DataType NormalDistribution::LogProbability( const DataType& observation) const { const DataType v1 = arma::log(sigma) + std::log(std::sqrt(2 * M_PI)); - const DataType v2 = square(observation - mean) / - (2 * square(sigma)); + const DataType v2 = square(observation - mean) / (2 * square(sigma)); return (-v1 - v2); } @@ -57,8 +56,7 @@ void NormalDistribution::ProbBackward( DataType& dsigma) const { dmu = (observation - mean) / (square(sigma)) % Probability(observation); - dsigma = (- 1.0 / sigma + - (square(observation - mean) / arma::pow(sigma, 3))) + dsigma = (- 1.0 / sigma + (square(observation - mean) / arma::pow(sigma, 3))) % Probability(observation); } diff --git a/src/mlpack/methods/ann/layer/linear3d_impl.hpp b/src/mlpack/methods/ann/layer/linear3d_impl.hpp index 76c63f11b5..bece2c60e8 100644 --- a/src/mlpack/methods/ann/layer/linear3d_impl.hpp +++ b/src/mlpack/methods/ann/layer/linear3d_impl.hpp @@ -172,8 +172,7 @@ void Linear3DType::Gradient( dW.slice(i) = errorTemp.slice(i) * inputTemp.slice(i).t(); } - gradient.submat(0, 0, weight.n_elem - 1, 0) - = vectorise(arma::sum(dW, 2)); + gradient.submat(0, 0, weight.n_elem - 1, 0) = vectorise(arma::sum(dW, 2)); gradient.submat(weight.n_elem, 0, weights.n_elem - 1, 0) = vectorise(arma::sum(arma::sum(errorTemp, 2), 1)); diff --git a/src/mlpack/methods/ann/layer/linear_impl.hpp b/src/mlpack/methods/ann/layer/linear_impl.hpp index 8543fe0d2d..be5d6b8eb3 100644 --- a/src/mlpack/methods/ann/layer/linear_impl.hpp +++ b/src/mlpack/methods/ann/layer/linear_impl.hpp @@ -128,8 +128,7 @@ void LinearType::Gradient( const MatType& error, MatType& gradient) { - gradient.submat(0, 0, weight.n_elem - 1, 0) = vectorise( - error * input.t()); + gradient.submat(0, 0, weight.n_elem - 1, 0) = vectorise(error * input.t()); gradient.submat(weight.n_elem, 0, gradient.n_elem - 1, 0) = arma::sum(error, 1); diff --git a/src/mlpack/methods/ann/layer/linear_no_bias_impl.hpp b/src/mlpack/methods/ann/layer/linear_no_bias_impl.hpp index 95c4d2dbfc..537f33ee7f 100644 --- a/src/mlpack/methods/ann/layer/linear_no_bias_impl.hpp +++ b/src/mlpack/methods/ann/layer/linear_no_bias_impl.hpp @@ -123,8 +123,7 @@ void LinearNoBiasType::Gradient( const MatType& error, MatType& gradient) { - gradient.submat(0, 0, weight.n_elem - 1, 0) = vectorise( - error * input.t()); + gradient.submat(0, 0, weight.n_elem - 1, 0) = vectorise(error * input.t()); regularizer.Evaluate(weight, gradient); } diff --git a/src/mlpack/methods/ann/layer/lstm_impl.hpp b/src/mlpack/methods/ann/layer/lstm_impl.hpp index d83b3fff50..68b3ab6ef8 100644 --- a/src/mlpack/methods/ann/layer/lstm_impl.hpp +++ b/src/mlpack/methods/ann/layer/lstm_impl.hpp @@ -344,26 +344,22 @@ void LSTMType::Gradient( // output2GateOutputWeight gradients. gradient.submat(offset, 0, offset + output2GateOutputWeight.n_elem - 1, 0) = - vectorise(outputGateError * - outParameter.slice(this->CurrentStep()).t()); + vectorise(outputGateError * outParameter.slice(this->CurrentStep()).t()); offset += output2GateOutputWeight.n_elem; // output2GateForgetWeight gradients. gradient.submat(offset, 0, offset + output2GateForgetWeight.n_elem - 1, 0) = - vectorise(forgetGateError * - outParameter.slice(this->CurrentStep()).t()); + vectorise(forgetGateError * outParameter.slice(this->CurrentStep()).t()); offset += output2GateForgetWeight.n_elem; // output2GateInputWeight gradients. gradient.submat(offset, 0, offset + output2GateInputWeight.n_elem - 1, 0) = - vectorise(inputGateError * - outParameter.slice(this->CurrentStep()).t()); + vectorise(inputGateError * outParameter.slice(this->CurrentStep()).t()); offset += output2GateInputWeight.n_elem; // output2HiddenWeight gradients. gradient.submat(offset, 0, offset + output2HiddenWeight.n_elem - 1, 0) = - vectorise(hiddenError * - outParameter.slice(this->CurrentStep()).t()); + vectorise(hiddenError * outParameter.slice(this->CurrentStep()).t()); offset += output2HiddenWeight.n_elem; // cell2GateOutputWeight gradients. diff --git a/src/mlpack/methods/ann/loss_functions/mean_squared_error_impl.hpp b/src/mlpack/methods/ann/loss_functions/mean_squared_error_impl.hpp index 2448deaac5..974ce21dde 100644 --- a/src/mlpack/methods/ann/loss_functions/mean_squared_error_impl.hpp +++ b/src/mlpack/methods/ann/loss_functions/mean_squared_error_impl.hpp @@ -29,8 +29,7 @@ typename MatType::elem_type MeanSquaredErrorType::Forward( const MatType& prediction, const MatType& target) { - typename MatType::elem_type lossSum = - arma::accu(square(prediction - target)); + typename MatType::elem_type lossSum = arma::accu(square(prediction - target)); if (reduction) return lossSum; diff --git a/src/mlpack/methods/ann/loss_functions/mean_squared_logarithmic_error_impl.hpp b/src/mlpack/methods/ann/loss_functions/mean_squared_logarithmic_error_impl.hpp index 5212247be9..fd48c7f36d 100644 --- a/src/mlpack/methods/ann/loss_functions/mean_squared_logarithmic_error_impl.hpp +++ b/src/mlpack/methods/ann/loss_functions/mean_squared_logarithmic_error_impl.hpp @@ -31,8 +31,7 @@ typename MatType::elem_type MeanSquaredLogarithmicErrorType::Forward( const MatType& target) { typename MatType::elem_type lossSum = - arma::accu(square(arma::log(1.0 + target) - - arma::log(1.0 + prediction))); + arma::accu(square(arma::log(1.0 + target) - arma::log(1.0 + prediction))); if (reduction) return lossSum; diff --git a/src/mlpack/methods/cf/neighbor_search_policies/pearson_search.hpp b/src/mlpack/methods/cf/neighbor_search_policies/pearson_search.hpp index 24e7fce84b..759e6c2824 100644 --- a/src/mlpack/methods/cf/neighbor_search_policies/pearson_search.hpp +++ b/src/mlpack/methods/cf/neighbor_search_policies/pearson_search.hpp @@ -57,8 +57,7 @@ class PearsonSearch // For each vector x, first subtract mean(x) from each element in x. // Then normalize the vector to unit length. arma::mat normalizedSet(arma::size(referenceSet)); - normalizedSet = normalise( - referenceSet.each_row() - arma::mean(referenceSet)); + normalizedSet = normalise(referenceSet.each_row() - arma::mean(referenceSet)); neighborSearch.Train(std::move(normalizedSet)); }