Fix warnings found by clang.

This commit is contained in:
Relintai 2023-04-16 16:05:50 +02:00
parent 6970af9363
commit 624fd34433
8 changed files with 18 additions and 13 deletions

View File

@ -197,10 +197,10 @@ void MLPPExpReg::mbgd(real_t learning_rate, int max_epoch, int mini_batch_size,
_weights = regularization.reg_weightsv(_weights, _lambda, _alpha, _reg); _weights = regularization.reg_weightsv(_weights, _lambda, _alpha, _reg);
// Calculating the bias gradient // Calculating the bias gradient
real_t sum = 0; //real_t sum = 0;
for (int j = 0; j < current_output_batch->size(); j++) { //for (int j = 0; j < current_output_batch->size(); j++) {
sum += (y_hat->get_element(j) - current_output_batch->get_element(j)); // sum += (y_hat->get_element(j) - current_output_batch->get_element(j));
} //}
//real_t b_gradient = sum / output_mini_batches[i].size(); //real_t b_gradient = sum / output_mini_batches[i].size();
y_hat = evaluatem(current_input_batch); y_hat = evaluatem(current_input_batch);
@ -288,7 +288,7 @@ Ref<MLPPVector> MLPPExpReg::evaluatem(const Ref<MLPPMatrix> &X) {
y_hat->resize(X->size().y); y_hat->resize(X->size().y);
for (int i = 0; i < X->size().y; i++) { for (int i = 0; i < X->size().y; i++) {
real_t y; real_t y = 0;
for (int j = 0; j < X->size().x; j++) { for (int j = 0; j < X->size().x; j++) {
y += _initial->get_element(j) * Math::pow(_weights->get_element(j), X->get_element(i, j)); y += _initial->get_element(j) * Math::pow(_weights->get_element(j), X->get_element(i, j));

View File

@ -182,10 +182,10 @@ void MLPPExpRegOld::MBGD(real_t learning_rate, int max_epoch, int mini_batch_siz
weights = regularization.regWeights(weights, lambda, alpha, reg); weights = regularization.regWeights(weights, lambda, alpha, reg);
// Calculating the bias gradient // Calculating the bias gradient
real_t sum = 0; //real_t sum = 0;
for (uint32_t j = 0; j < outputMiniBatches[i].size(); j++) { //for (uint32_t j = 0; j < outputMiniBatches[i].size(); j++) {
sum += (y_hat[j] - outputMiniBatches[i][j]); // sum += (y_hat[j] - outputMiniBatches[i][j]);
} //}
//real_t b_gradient = sum / outputMiniBatches[i].size(); //real_t b_gradient = sum / outputMiniBatches[i].size();
y_hat = Evaluate(inputMiniBatches[i]); y_hat = Evaluate(inputMiniBatches[i]);

View File

@ -292,6 +292,8 @@ public:
for (int i = 0; i < _size.x; ++i) { for (int i = 0; i < _size.x; ++i) {
row_ptr[i] = _data[ind_start + i]; row_ptr[i] = _data[ind_start + i];
} }
return ret;
} }
_FORCE_INLINE_ PoolRealArray get_row_pool_vector(int p_index_y) { _FORCE_INLINE_ PoolRealArray get_row_pool_vector(int p_index_y) {

View File

@ -293,6 +293,8 @@ public:
for (int i = 0; i < _size.x; ++i) { for (int i = 0; i < _size.x; ++i) {
row_ptr[i] = _data[ind_start + i]; row_ptr[i] = _data[ind_start + i];
} }
return ret;
} }
_FORCE_INLINE_ PoolRealArray get_row_pool_vector(int p_index_y) { _FORCE_INLINE_ PoolRealArray get_row_pool_vector(int p_index_y) {
@ -644,6 +646,7 @@ public:
} }
} }
// TODO: These are temporary // TODO: These are temporary
std::vector<real_t> to_flat_std_vector() const; std::vector<real_t> to_flat_std_vector() const;
void set_from_std_vectors(const std::vector<std::vector<real_t>> &p_from); void set_from_std_vectors(const std::vector<std::vector<real_t>> &p_from);

View File

@ -76,7 +76,7 @@ protected:
int _n; int _n;
int _k; int _k;
real_t _learning_rate; //real_t _learning_rate;
// Regularization Params // Regularization Params
MLPPReg::RegularizationType _reg; MLPPReg::RegularizationType _reg;

View File

@ -40,7 +40,7 @@ private:
int n; int n;
int k; int k;
real_t learning_rate; //real_t learning_rate;
// Regularization Params // Regularization Params
std::string reg; std::string reg;

View File

@ -77,7 +77,7 @@ real_t MLPPNumericalAnalysis::numDiff_3(real_t (*function)(std::vector<real_t>),
// For third order derivative tensors. // For third order derivative tensors.
// NOTE: Approximations do not appear to be accurate for sinusodial functions... // NOTE: Approximations do not appear to be accurate for sinusodial functions...
// Should revisit this later. // Should revisit this later.
real_t eps = INT_MAX; real_t eps = 1e-5;
std::vector<real_t> x_ppp = x; std::vector<real_t> x_ppp = x;
x_ppp[axis1] += eps; x_ppp[axis1] += eps;

View File

@ -77,7 +77,7 @@ real_t MLPPNumericalAnalysisOld::numDiff_3(real_t (*function)(std::vector<real_t
// For third order derivative tensors. // For third order derivative tensors.
// NOTE: Approximations do not appear to be accurate for sinusodial functions... // NOTE: Approximations do not appear to be accurate for sinusodial functions...
// Should revisit this later. // Should revisit this later.
real_t eps = INT_MAX; real_t eps = 1e-5;
std::vector<real_t> x_ppp = x; std::vector<real_t> x_ppp = x;
x_ppp[axis1] += eps; x_ppp[axis1] += eps;