Skip to content
Snippets Groups Projects
Commit 4d7b57d7 authored by Martin Beseda's avatar Martin Beseda
Browse files

FIX: Fixed memory leaks

parent 23500446
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ namespace lib4neuro {
this->n_elements = 0;
this->input_dim = 0;
this->output_dim = 0;
this->normalization_strategy = std::make_shared<DoubleUnitStrategy>(DoubleUnitStrategy());
}
DataSet::DataSet(std::string file_path) {
......@@ -34,9 +35,11 @@ namespace lib4neuro {
THROW_RUNTIME_ERROR("File " + file_path + " couldn't be open!");
}
this->normalization_strategy = std::make_shared<DoubleUnitStrategy>(DoubleUnitStrategy());
}
DataSet::DataSet(std::vector<std::pair<std::vector<double>, std::vector<double>>> *data_ptr,
DataSet::DataSet(std::vector<std::pair<std::vector<double>, std::vector<double>>>* data_ptr,
NormalizationStrategy* ns) {
this->n_elements = data_ptr->size();
this->data = *data_ptr;
......@@ -44,7 +47,9 @@ namespace lib4neuro {
this->output_dim = this->data[0].second.size();
if(ns) {
this->normalization_strategy = ns;
std::shared_ptr<NormalizationStrategy> ns_tmp;
ns_tmp.reset(ns);
this->normalization_strategy = ns_tmp;
// this->max_min_inp_val.emplace_back(this->normalization_strategy->get_max_value());
// this->max_min_inp_val.emplace_back(this->normalization_strategy->get_min_value());
}
......@@ -64,7 +69,9 @@ namespace lib4neuro {
this->output_dim = 1;
if(ns) {
this->normalization_strategy = ns;
std::shared_ptr<NormalizationStrategy> ns_tmp;
ns_tmp.reset(ns);
this->normalization_strategy = ns_tmp;
// this->max_min_inp_val.emplace_back(this->normalization_strategy->get_max_value());
// this->max_min_inp_val.emplace_back(this->normalization_strategy->get_min_value());
}
......@@ -84,7 +91,9 @@ namespace lib4neuro {
this->n_elements = 0;
if(ns) {
this->normalization_strategy = ns;
std::shared_ptr<NormalizationStrategy> ns_tmp;
ns_tmp.reset(ns);
this->normalization_strategy = ns_tmp;
}
this->add_isotropic_data(bounds, no_elems_in_one_dim, output_func);
......@@ -389,7 +398,7 @@ namespace lib4neuro {
}
NormalizationStrategy* DataSet::get_normalization_strategy() {
return this->normalization_strategy;
return this->normalization_strategy.get();
}
bool DataSet::is_normalized() {
......
......@@ -12,6 +12,7 @@
#include <string>
#include <functional>
#include <limits>
#include <memory>
#include "../settings.h"
#include "../NormalizationStrategy/NormalizationStrategy.h"
......@@ -77,7 +78,7 @@ namespace lib4neuro {
*
*/
//TODO let user choose in the constructor!
NormalizationStrategy* normalization_strategy = new DoubleUnitStrategy;
std::shared_ptr<NormalizationStrategy> normalization_strategy;
// /**
// *
......
......@@ -12,6 +12,7 @@
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/export.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include "DataSet.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment