Commit 76dd9f9c authored by Michal Kravcenko's avatar Michal Kravcenko

-added a new test showcasing the use of subnetworks sharing edge weights and...

-added a new test showcasing the use of subnetworks sharing edge weights and multiple error functions in swarm optimization
parent 39503418
......@@ -34,6 +34,9 @@ target_link_libraries(net_test_1 4neuro)
add_executable(net_test_2 net_test_2.cpp)
target_link_libraries(net_test_2 4neuro)
add_executable(net_test_3 net_test_3.cpp)
target_link_libraries(net_test_3 4neuro)
##############
# UNIT TESTS #
##############
......
......@@ -72,7 +72,7 @@ public:
* @param weights
* @return
*/
virtual double eval(double* weights);
virtual double eval(double* weights = nullptr);
/**
*
......
/**
* Example of a set of neural networks sharing some edge weights
*/
* The system of equations associated with the net in this example is not regular
* minimizes the function: [(2y+0.5)^2 + (2x+y+0.25)^2] / 2 + [(4.5x + 0.37)^2] / 1
* minimum [0,010024714] at (x, y) = (-333/4370, -9593/43700) = (-0.076201373, -0.219519451)
* */
//
// Created by martin on 7/16/18.
......@@ -17,15 +20,15 @@ int main() {
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_vec_01, data_vec_02;
std::vector<double> inp, out;
inp = {0, 1, 0};
out = {0.5, 0};
inp = {0, 1};
out = {0.5};
data_vec_01.emplace_back(std::make_pair(inp, out));
inp = {1, 0.5, 0};
out = {0.75, 0};
inp = {1, 0.5};
out = {0.75};
data_vec_01.emplace_back(std::make_pair(inp, out));
// DataSet ds_01(&data_vec_01);
DataSet ds_01(&data_vec_01);
inp = {1.25};
......@@ -101,7 +104,7 @@ int main() {
/* TRAINING METHOD SETUP */
unsigned int n_edges = 2;
unsigned int dim = n_edges, max_iters = 5000;
unsigned int dim = n_edges, max_iters = 50;
//must encapsulate each of the partial error functions
......@@ -109,12 +112,13 @@ int main() {
double c1 = 0.5, c2 = 1.5, w = 0.8;
unsigned int n_particles = 10;
unsigned int n_particles = 100;
ParticleSwarm swarm_01(&mse_sum, domain_bounds, c1, c2, w, n_particles, max_iters);
swarm_01.optimize(0.5, 0.02);
swarm_01.optimize(0.5, 0.02, 0.9);
printf("evaluation of error: %f\n", mse_sum.eval());
delete subnet_02;
delete subnet_01;
......
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