Skip to content
Snippets Groups Projects
Commit f7aec172 authored by Michal Kravcenko's avatar Michal Kravcenko
Browse files

MOD: added export information to a few learning methods

parent c8bf3ed6
No related branches found
Tags
No related merge requests found
...@@ -239,10 +239,17 @@ namespace lib4neuro { ...@@ -239,10 +239,17 @@ namespace lib4neuro {
COUT_DEBUG("Iteration: " << iter_counter << " Current error: " << current_err << ", Current gradient norm: " COUT_DEBUG("Iteration: " << iter_counter << " Current error: " << current_err << ", Current gradient norm: "
<< gradient_norm << ", Direction norm: " << update_norm << "\r"); << gradient_norm << ", Direction norm: " << update_norm << "\r");
if (ofs && ofs->is_open()) {
*ofs << "Iteration: " << iter_counter << " Current error: " << current_err << ", Current gradient norm: "
<< gradient_norm << ", Direction norm: " << update_norm << std::endl;
}
} while (iter_counter++ < this->p_impl->maximum_niters && (update_norm > this->p_impl->tolerance)); } while (iter_counter++ < this->p_impl->maximum_niters && (update_norm > this->p_impl->tolerance));
COUT_DEBUG("Iteration: " << iter_counter << " Current error: " << current_err << ", Current gradient norm: " COUT_DEBUG("Iteration: " << iter_counter << " Current error: " << current_err << ", Current gradient norm: "
<< gradient_norm << ", Direction norm: " << update_norm << std::endl); << gradient_norm << ", Direction norm: " << update_norm << std::endl);
if (ofs && ofs->is_open()) {
*ofs << "Iteration: " << iter_counter << " Current error: " << current_err << ", Current gradient norm: "
<< gradient_norm << ", Direction norm: " << update_norm << std::endl;
}
/* Store the optimized parameters */ /* Store the optimized parameters */
this->optimal_parameters = *params_current; this->optimal_parameters = *params_current;
......
...@@ -295,6 +295,9 @@ namespace lib4neuro { ...@@ -295,6 +295,9 @@ namespace lib4neuro {
//TODO add output to the 'ofs' //TODO add output to the 'ofs'
COUT_INFO("Finding optima via Globalized Particle Swarm method..." << std::endl); COUT_INFO("Finding optima via Globalized Particle Swarm method..." << std::endl);
if (ofs && ofs->is_open()) {
*ofs << "Finding optima via Globalized Particle Swarm method..." << std::endl;
}
if (this->epsilon < 0 || this->gamma < 0 || this->delta < 0) { if (this->epsilon < 0 || this->gamma < 0 || this->delta < 0) {
THROW_INVALID_ARGUMENT_ERROR( THROW_INVALID_ARGUMENT_ERROR(
...@@ -422,6 +425,13 @@ namespace lib4neuro { ...@@ -422,6 +425,13 @@ namespace lib4neuro {
<< ". Total error: " << current_err << ". Total error: " << current_err
<< ". Objective function value: " << optimal_value << ". Objective function value: " << optimal_value
<< ".\r"); << ".\r");
if (ofs && ofs->is_open()) {
*ofs << "Iteration: " << (outer_it)
<< ". Total error: " << current_err
<< ". Objective function value: " << optimal_value
<< std::endl;
}
if (this->err_thresh) { if (this->err_thresh) {
...@@ -447,6 +457,12 @@ namespace lib4neuro { ...@@ -447,6 +457,12 @@ namespace lib4neuro {
<< ". Total error: " << current_err << ". Total error: " << current_err
<< ". Objective function value: " << optimal_value << ". Objective function value: " << optimal_value
<< "." << std::endl); << "." << std::endl);
if (ofs && ofs->is_open()) {
*ofs << "Iteration: " << (outer_it)
<< ". Total error: " << current_err
<< ". Objective function value: " << optimal_value
<< std::endl;
}
this->determine_optimal_coordinate_and_value(this->optimal_parameters, this->determine_optimal_coordinate_and_value(this->optimal_parameters,
optimal_value); optimal_value);
...@@ -455,10 +471,18 @@ namespace lib4neuro { ...@@ -455,10 +471,18 @@ namespace lib4neuro {
/* Convergence reached */ /* Convergence reached */
COUT_INFO(std::endl << "Found optimum in " << outer_it << " iterations. Objective function value: " COUT_INFO(std::endl << "Found optimum in " << outer_it << " iterations. Objective function value: "
<< optimal_value << std::endl); << optimal_value << std::endl);
if (ofs && ofs->is_open()) {
*ofs << "Found optimum in " << outer_it << " iterations. Objective function value: "
<< optimal_value << std::endl;
}
} else { } else {
/* Maximal number of iterations reached */ /* Maximal number of iterations reached */
COUT_INFO(std::endl << "Max number of iterations reached (" << outer_it << ")! Objective function value: " COUT_INFO(std::endl << "Max number of iterations reached (" << outer_it << ")! Objective function value: "
<< optimal_value << std::endl); << optimal_value << std::endl);
if (ofs && ofs->is_open()) {
*ofs << "Max number of iterations reached (" << outer_it << ")! Objective function value: "
<< optimal_value << std::endl;
}
} }
ef.set_parameters(this->optimal_parameters); ef.set_parameters(this->optimal_parameters);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment