Commit f31cb7a2 authored by Martin Beseda's avatar Martin Beseda

FIX: Fixed memory error

parent 3364b06f
......@@ -68,4 +68,18 @@ void MSE_SUM::add_error_function(ErrorFunction *F) {
this->summand = new std::vector<ErrorFunction*>(0);
}
this->summand->push_back(F);
}
size_t MSE_SUM::get_dimension() {
if(!this->dimension) {
size_t max = 0;
for(auto e : *this->summand) {
if(e->get_dimension() > max) {
max = e->get_dimension();
}
};
this->dimension = max;
}
return this->dimension;
}
\ No newline at end of file
......@@ -29,7 +29,7 @@ protected:
/**
*
*/
size_t dimension;
size_t dimension = 0;
};
class MSE : public ErrorFunction {
......@@ -80,8 +80,14 @@ public:
*/
void add_error_function(ErrorFunction *F);
/**
*
* @return
*/
size_t get_dimension() override;
private:
std::vector<ErrorFunction*> *summand;
std::vector<ErrorFunction*>* summand;
};
......
......@@ -370,7 +370,7 @@ void NeuralNetwork::eval_single(std::vector<double> &input, std::vector<double>
if(!this->in_out_determined && this->n_inputs * this->n_outputs <= 0){
// this->determine_inputs_outputs();
std::cerr << "Input and output neurons have not been specified\n" << std::endl;
exit(-sin1);
exit(-1);
}
......
......@@ -101,7 +101,7 @@ int main() {
/* TRAINING METHOD SETUP */
unsigned int n_edges = 2;
unsigned int dim = n_edges, max_iters = 2000;
unsigned int dim = n_edges, max_iters = 5000;
//must encapsulate each of the partial error functions
......@@ -109,7 +109,7 @@ int main() {
double c1 = 0.5, c2 = 1.5, w = 0.8;
unsigned int n_particles = 10;
unsigned int n_particles = 10000;
ParticleSwarm swarm_01(&mse_sum, domain_bounds, c1, c2, w, n_particles, max_iters);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment