mirror of
https://github.com/Relintai/pmlpp.git
synced 2024-12-22 15:06:47 +01:00
Fixed warnings in MLPPTanhReg.
This commit is contained in:
parent
4e30b31833
commit
e191ab9a16
@ -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 <iostream>
|
||||
#include <random>
|
||||
|
||||
|
||||
MLPPTanhReg::MLPPTanhReg(std::vector<std::vector<real_t>> inputSet, std::vector<real_t> 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<real_t> x) {
|
||||
|
||||
// Tanh ( wTx + b )
|
||||
void MLPPTanhReg::forwardPass() {
|
||||
MLPPLinAlg alg;
|
||||
MLPPActivation avn;
|
||||
|
||||
z = propagate(inputSet);
|
||||
|
@ -13,8 +13,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
class MLPPTanhReg {
|
||||
public:
|
||||
MLPPTanhReg(std::vector<std::vector<real_t>> inputSet, std::vector<real_t> 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 */
|
||||
|
Loading…
Reference in New Issue
Block a user