From e191ab9a1631f7adf8a38f4741ae5d249680da3f Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 10 Feb 2023 20:53:26 +0100 Subject: [PATCH] Fixed warnings in MLPPTanhReg. --- mlpp/tanh_reg/tanh_reg.cpp | 12 +++++++----- mlpp/tanh_reg/tanh_reg.h | 3 --- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mlpp/tanh_reg/tanh_reg.cpp b/mlpp/tanh_reg/tanh_reg.cpp index f1d4f39..87e7bb8 100644 --- a/mlpp/tanh_reg/tanh_reg.cpp +++ b/mlpp/tanh_reg/tanh_reg.cpp @@ -5,6 +5,7 @@ // #include "tanh_reg.h" + #include "../activation/activation.h" #include "../cost/cost.h" #include "../lin_alg/lin_alg.h" @@ -14,7 +15,6 @@ #include #include - MLPPTanhReg::MLPPTanhReg(std::vector> inputSet, std::vector outputSet, std::string reg, real_t lambda, real_t alpha) : inputSet(inputSet), outputSet(outputSet), n(inputSet.size()), k(inputSet[0].size()), reg(reg), lambda(lambda), alpha(alpha) { y_hat.resize(n); @@ -107,12 +107,15 @@ void MLPPTanhReg::MBGD(real_t learning_rate, int max_epoch, int mini_batch_size, MLPPActivation avn; MLPPLinAlg alg; MLPPReg regularization; + real_t cost_prev = 0; int epoch = 1; // Creating the mini-batches int n_mini_batch = n / mini_batch_size; - auto [inputMiniBatches, outputMiniBatches] = MLPPUtilities::createMiniBatches(inputSet, outputSet, n_mini_batch); + auto batches = MLPPUtilities::createMiniBatches(inputSet, outputSet, n_mini_batch); + auto inputMiniBatches = std::get<0>(batches); + auto outputMiniBatches = std::get<1>(batches); while (true) { for (int i = 0; i < n_mini_batch; i++) { @@ -147,12 +150,12 @@ void MLPPTanhReg::MBGD(real_t learning_rate, int max_epoch, int mini_batch_size, } real_t MLPPTanhReg::score() { - MLPPUtilities util; + MLPPUtilities util; return util.performance(y_hat, outputSet); } void MLPPTanhReg::save(std::string fileName) { - MLPPUtilities util; + MLPPUtilities util; util.saveParameters(fileName, weights, bias); } @@ -186,7 +189,6 @@ real_t MLPPTanhReg::propagate(std::vector x) { // Tanh ( wTx + b ) void MLPPTanhReg::forwardPass() { - MLPPLinAlg alg; MLPPActivation avn; z = propagate(inputSet); diff --git a/mlpp/tanh_reg/tanh_reg.h b/mlpp/tanh_reg/tanh_reg.h index 3a97131..c23528b 100644 --- a/mlpp/tanh_reg/tanh_reg.h +++ b/mlpp/tanh_reg/tanh_reg.h @@ -13,8 +13,6 @@ #include #include - - class MLPPTanhReg { public: MLPPTanhReg(std::vector> inputSet, std::vector outputSet, std::string reg = "None", real_t lambda = 0.5, real_t alpha = 0.5); @@ -54,5 +52,4 @@ private: real_t alpha; /* This is the controlling param for Elastic Net*/ }; - #endif /* TanhReg_hpp */