...
 
Commits (706)
......@@ -3,6 +3,7 @@ stages:
# Windows 10 with dependencies
# downloaded (and compiled) locally
# compiled by VisualStudio 2017
win_visual_studio_static_local_deps:
tags:
- Win
......@@ -12,17 +13,39 @@ win_visual_studio_static_local_deps:
stage: build
before_script:
- rmdir /s /q build external_dependencies/*
- call VsDevCmd.bat
- set DEPENDENCIES_LINK_TYPE=static
- set clean_after=yes
- set BUILD_LIB=yes
- set BUILD_EXAMPLES=yes
- set BUILD_TESTS=yes
- call build_scripts\windows\win_VS_build_x64_release.bat
script:
- call build_scripts\windows\win_VS_build_x64_release.bat
# Windows 10 with dependencies
# downloaded (and compiled) locally
# compiled by VisualStudio 2015
win_visual_studio_2015_static_local_deps:
tags:
- Win
image: windows:latest
stage: build
before_script:
- rmdir /s /q build external_dependencies/*
- set DEPENDENCIES_LINK_TYPE=static
- set clean_after=yes
- set BUILD_LIB=yes
- set BUILD_EXAMPLES=yes
- set BUILD_TESTS=yes
script:
- call build_scripts\windows\win_VS2015_build_x64_release.bat
# Latest Ubuntu with dependencies
# in system directories, Boost
# installed from the official repository
......@@ -32,6 +55,7 @@ ubuntu_boost_system:
stage: build
before_script:
- rm -rf build external_dependencies/*
- export TERM=xterm
- export DEPENDENCIES_LINK_TYPE=shared
- export CLEAN_AFTER=yes
......@@ -50,6 +74,7 @@ ubuntu_boost_local_static_deps:
stage: build
before_script:
- rm -rf build external_dependencies/*
- export TERM=xterm
- export DEPENDENCIES_LINK_TYPE=static
- export CLEAN_AFTER=yes
......@@ -68,6 +93,7 @@ centos_local_deps:
stage: build
before_script:
- rm -rf build external_dependencies/*
- export TERM=xterm
- export DEPENDENCIES_LINK_TYPE=static
- export CLEAN_AFTER=yes
......
File mode changed from 100755 to 100644
#!/usr/bin/sh
ml CMake/3.13.1
ml GCC/7.1.0-2.28
ml Boost
ml Armadillo
ml OpenBLAS
ml ScaLAPACK
./clean.sh
./build.sh
\ No newline at end of file
@echo off
title Building the 'lib4neuro' project for Release
set BUILD_SOMETHING_LIB=yes
set BUILD_LIB=yes
set BUILD_TESTS=yes
set BUILD_EXAMPLES=yes
rem call VsDevCmd.bat
title Building the 'lib4neuro' project for Release [preparing makefiles]
rem C++ compiler (Requires Visual Studio 2015)
set CXX_COMPILER=cl
set C_COMPILER=cl
set MAKEFILE_GENERATOR="Visual Studio 14 2015 Win64"
cmake -G %MAKEFILE_GENERATOR% -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=%CXX_COMPILER% -DCMAKE_C_COMPILER=%C_COMPILER% -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% -DBOOST_INCLUDEDIR=%BOOST_INCLUDEDIR% -DBUILD_TESTS=%BUILD_TESTS% -DBUILD_EXAMPLES=%BUILD_EXAMPLES% -DBUILD_LIB=%BUILD_LIB% -DLIB4NEURO_DIR=build\lib -DDEPENDENCIES_LINK_TYPE=%LINK_TYPE% -DLIB4NEURO_INCLUDE_DIR=%LIB4NEURO_INCLUDE_DIR% -S . -B build
title Building the 'lib4neuro' project for Release [building]
call set_env_n_cores.bat
if "%BUILD_SOMETHING_LIB%" == "yes" (
cmake --build build -j %N_CORES% --config Release && echo "Build complete."
)
......@@ -16,7 +16,7 @@ rem call VsDevCmd.bat
set MAKEFILE_GENERATOR="Visual Studio 15 2017 Win64"
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=%CXX_COMPILER% -DCMAKE_C_COMPILER=%C_COMPILER% -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% -DBOOST_INCLUDEDIR=%BOOST_INCLUDEDIR% -DBUILD_TESTS=%BUILD_TESTS% -DBUILD_EXAMPLES=%BUILD_EXAMPLES% -DBUILD_LIB=%BUILD_LIB% -DLIB4NEURO_DIR=build\lib -DDEPENDENCIES_LINK_TYPE=%LINK_TYPE% -DLIB4NEURO_INCLUDE_DIR=%LIB4NEURO_INCLUDE_DIR% -S . -B build
cmake -G %MAKEFILE_GENERATOR% -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=%CXX_COMPILER% -DCMAKE_C_COMPILER=%C_COMPILER% -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% -DBOOST_INCLUDEDIR=%BOOST_INCLUDEDIR% -DBUILD_TESTS=%BUILD_TESTS% -DBUILD_EXAMPLES=%BUILD_EXAMPLES% -DBUILD_LIB=%BUILD_LIB% -DLIB4NEURO_DIR=build\lib -DDEPENDENCIES_LINK_TYPE=%LINK_TYPE% -DLIB4NEURO_INCLUDE_DIR=%LIB4NEURO_INCLUDE_DIR% -S . -B build
title Building the 'lib4neuro' project for Release [building]
call set_env_n_cores.bat
......
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
......@@ -135,4 +135,4 @@ namespace lib4neuro {
return std::make_shared<DataSet>(DataSet(&data_set_contents));
}
}
\ No newline at end of file
}
......@@ -240,15 +240,15 @@ namespace lib4neuro {
for (auto e : this->data) {
/* First part of the pair */
for (unsigned int i = 0; i < e.first.size() - 1; i++) {
*file_path << e.first.at(i) << ",";
*file_path << this->get_denormalized_value(e.first.at(i)) << ",";
}
*file_path << e.first.back() << " ";
*file_path << this->get_denormalized_value(e.first.back()) << " ";
/* Second part of the pair */
for (unsigned int i = 0; i < e.second.size() - 1; i++) {
*file_path << e.second.at(i) << ",";
*file_path << this->get_denormalized_value(e.second.at(i)) << ",";
}
*file_path << e.second.back() << std::endl;
*file_path << this->get_denormalized_value(e.second.back()) << std::endl;
}
}
......@@ -258,19 +258,8 @@ namespace lib4neuro {
if (!ofs.is_open()) {
THROW_RUNTIME_ERROR("File " + file_path + " couldn't be open!");
} else {
for (auto e : this->data) {
/* First part of the pair */
for (unsigned int i = 0; i < e.first.size() - 1; i++) {
ofs << e.first.at(i) << ",";
}
ofs << e.first.back() << " ";
/* Second part of the pair */
for (unsigned int i = 0; i < e.second.size() - 1; i++) {
ofs << e.second.at(i) << ",";
}
ofs << e.second.back() << std::endl;
}
this->store_data_text(&ofs);
ofs.close();
}
}
......
......@@ -173,7 +173,6 @@ namespace lib4neuro {
for (size_t i = 0; i < data->size(); i++) {
/* Compute difference for every element of the output vector */
#ifdef L4N_DEBUG
std::stringstream ss_input;
for (size_t j = 0; j < dim_in; j++) {
denormalized_real_input = data_set->get_denormalized_value(data->at(i).first.at(j));
......@@ -183,7 +182,6 @@ namespace lib4neuro {
std::stringstream ss_real_output;
std::stringstream ss_predicted_output;
#endif
double loc_error = 0;
output_norm = 0;
......@@ -192,11 +190,9 @@ namespace lib4neuro {
denormalized_real_output = data_set->get_denormalized_value(data->at(i).second.at(j));
denormalized_output = data_set->get_denormalized_value(outputs.at(i).at(j));
#ifdef L4N_DEBUG
ss_real_output << separator << denormalized_real_output;
ss_predicted_output << separator << denormalized_output;
separator = ",";
#endif
val = denormalized_output - denormalized_real_output;
loc_error += val * val;
......@@ -205,9 +201,9 @@ namespace lib4neuro {
output_norm += denormalized_output * denormalized_output;
}
#ifdef L4N_DEBUG
std::stringstream ss_ind;
ss_ind << "[" << i << "]";
#ifdef L4N_DEBUG
if (verbose) {
COUT_DEBUG(R_ALIGN << ss_ind.str() << " "
......@@ -220,6 +216,8 @@ namespace lib4neuro {
<< std::endl);
}
#endif
if (results_file_path) {
*results_file_path << R_ALIGN << ss_ind.str() << " "
<< R_ALIGN << ss_input.str() << " "
......@@ -230,7 +228,6 @@ namespace lib4neuro {
<< 200.0 * std::sqrt(loc_error) / (std::sqrt(loc_error) + std::sqrt(output_norm))
<< std::endl;
}
#endif
}
double result = std::sqrt(error) / n_elements;
......
......@@ -18,7 +18,7 @@ namespace lib4neuro {
LearningSequence::~LearningSequence() = default;
void LearningSequence::add_learning_method(std::shared_ptr<LearningMethod> method) {
void LearningSequence::add_learning_method(LearningMethod *method) {
this->learning_sequence.push_back(method);
}
......@@ -58,4 +58,4 @@ namespace lib4neuro {
}
ef.set_parameters(this->optimal_parameters);
}
}
\ No newline at end of file
}
......@@ -24,7 +24,7 @@ namespace lib4neuro {
/**
*
*/
std::vector<std::shared_ptr<LearningMethod>> learning_sequence;
std::vector<LearningMethod*> learning_sequence;
/**
*
......@@ -62,7 +62,7 @@ namespace lib4neuro {
*
* @param method
*/
LIB4NEURO_API void add_learning_method(std::shared_ptr<LearningMethod> method);
LIB4NEURO_API void add_learning_method(LearningMethod *method);
};
}
......
......@@ -52,10 +52,19 @@ void lib4neuro::LevenbergMarquardt::LevenbergMarquardtImpl::get_jacobian_and_rhs
std::vector<std::vector<double>> jacobian;
std::vector<double> rhs_vec;
ef.divide_data_train_test((double) data_subset_size / (double) ef.get_n_data_set());
if (data_subset_size <= 0) {
data_subset_size = ef.get_n_data_set();
}
if (data_subset_size < ef.get_n_data_set()) {
ef.divide_data_train_test((double) data_subset_size / (double) ef.get_n_data_set());
}
ef.get_jacobian_and_rhs(jacobian,
rhs_vec);
ef.return_full_data_set_for_training();
if (data_subset_size < ef.get_n_data_set()) {
ef.return_full_data_set_for_training();
}
size_t dim_out = jacobian.size();
size_t n_parameters = rhs_vec.size();
......@@ -233,10 +242,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;
......@@ -253,4 +269,4 @@ namespace lib4neuro {
}
LevenbergMarquardt::~LevenbergMarquardt() = default;
}
\ No newline at end of file
}
......@@ -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);
......
......@@ -40,4 +40,4 @@ void ConnectionFunctionIdentity::eval_partial_derivative(std::vector<double>& pa
}
weight_gradient[this->param_idx] += alpha;
}
\ No newline at end of file
}
......@@ -140,4 +140,4 @@ namespace lib4neuro {
return output;
}
}
\ No newline at end of file
}
......@@ -2,7 +2,7 @@
#ifndef INC_4NEURO_CONSTANTS_H
#define INC_4NEURO_CONSTANTS_H
namespace lib4neuro {
namespace lib4neuro{
const double E = 2.7182818284590;
const double PI = 3.14159265358979323846;
}
......
......@@ -138,4 +138,4 @@ int main(int argc,
exit(EXIT_FAILURE);
}
}
\ No newline at end of file
}
......@@ -190,4 +190,4 @@ int main() {
<< "********************************************************************************************************************************************"
<< std::endl;
return 0;
}
\ No newline at end of file
}
......@@ -52,4 +52,4 @@ BOOST_AUTO_TEST_SUITE(Connection_test)
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
BOOST_AUTO_TEST_SUITE_END()