Commit f7aec172 authored by Michal Kravcenko's avatar Michal Kravcenko

MOD: added export information to a few learning methods

parent c8bf3ed6
......@@ -239,10 +239,17 @@ namespace lib4neuro {
COUT_DEBUG("Iteration: " << iter_counter << " Current error: " << current_err << ", Current gradient norm: "
<< 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));
COUT_DEBUG("Iteration: " << iter_counter << " Current error: " << current_err << ", Current gradient norm: "
<< 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 */
this->optimal_parameters = *params_current;
......
......@@ -295,6 +295,9 @@ namespace lib4neuro {
//TODO add output to the 'ofs'
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) {
THROW_INVALID_ARGUMENT_ERROR(
......@@ -422,6 +425,13 @@ namespace lib4neuro {
<< ". Total error: " << current_err
<< ". Objective function value: " << optimal_value
<< ".\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) {
......@@ -447,6 +457,12 @@ namespace lib4neuro {
<< ". Total error: " << current_err
<< ". Objective function value: " << optimal_value
<< "." << 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,
optimal_value);
......@@ -455,10 +471,18 @@ namespace lib4neuro {
/* Convergence reached */
COUT_INFO(std::endl << "Found optimum in " << outer_it << " iterations. Objective function value: "
<< optimal_value << std::endl);
if (ofs && ofs->is_open()) {
*ofs << "Found optimum in " << outer_it << " iterations. Objective function value: "
<< optimal_value << std::endl;
}
} else {
/* Maximal number of iterations reached */
COUT_INFO(std::endl << "Max number of iterations reached (" << outer_it << ")! Objective function value: "
<< 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);
......
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