Commit bc28b967 authored by Michal Kravcenko's avatar Michal Kravcenko

Commit after merge

parent 93281e20
......@@ -6,6 +6,7 @@
*/
//TODO incorporate uncertainities as coefficients in NeuralNetworkSum or ErrorSum
//TODO add support for multiple unknown functions to be found
#ifndef INC_4NEURO_PDESOLVER_H
#define INC_4NEURO_PDESOLVER_H
......
......@@ -44,14 +44,14 @@ void test1( ){
////////////////////// END SIMPLE EDGE WEIGHT ////////////////////////////////////////
/////////////////////////BEGIN OF COMPLEX EDGE WEIGHT//////////////////////////////
std::function<double(double *, int*, int)> weight_function = [](double * weight_array, int * index_array, int n_params){
std::function<double(double *, size_t*, size_t)> weight_function = [](double * weight_array, size_t * index_array, size_t n_params){
//w(x, y) = x + y
double a = weight_array[index_array[0]];
double b = weight_array[index_array[1]];
// printf("eval: %f, %f\n", a, b);
return (a + 0.0 * b);
};
int weight_indices [2] = {0, -1};
size_t weight_indices [2] = {0, 1};
double weight_values [2] = {1.0, 5.0};
net.add_connection_general(idx1, idx2, &weight_function, weight_indices, weight_values, 2);
/////////////////////////END OF COMPLEX EDGE WEIGHT//////////////////////////////
......
......@@ -91,7 +91,7 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test)
}
BOOST_AUTO_TEST_CASE(ErrorFunction_MSE_SUM_Construction_Test) {
BOOST_CHECK_NO_THROW(MSE_SUM mse_sum);
BOOST_CHECK_NO_THROW(ErrorSum mse_sum);
}
BOOST_AUTO_TEST_CASE(ErrorFunction_MSE_SUM_Add_Error_Function_Test) {
......@@ -107,12 +107,12 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test)
ErrorFunction *f = new MSE(&network, &dataSet);
MSE_SUM mse_sum;
ErrorSum mse_sum;
BOOST_CHECK_NO_THROW(mse_sum.add_error_function(f));
}
BOOST_AUTO_TEST_CASE(ErrorFunction_MSE_SUM_Eval_Test) {
MSE_SUM mse_sum;
ErrorSum mse_sum;
double weights[1] = {0};
Neuron *n1 = new NeuronLinear(1, 1);
......@@ -146,7 +146,7 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test)
}
BOOST_AUTO_TEST_CASE(ErrorFunction_MSE_SUM_Get_Dimension_test) {
MSE_SUM mse_sum;
ErrorSum mse_sum;
BOOST_CHECK_EQUAL(0, mse_sum.get_dimension());
Neuron *n1 = new NeuronLinear(1, 1);
......
......@@ -65,12 +65,12 @@ BOOST_AUTO_TEST_SUITE(NeuralNetwork_test)
Neuron *n2 = new NeuronLinear(2, 2);
network.add_neuron(n1);
network.add_neuron(n2);
std::function<double(double *, int *, int)> f = [](double *weight_array, int *index_array, int n_params) {
std::function<double(double *, size_t *, size_t)> f = [](double *weight_array, size_t *index_array, size_t n_params) {
double a = weight_array[0];
double b = weight_array[1];
return (a + 1.5 * b);
};
int para[5] = {0, 1, 2, 3, 4};
size_t para[5] = {0, 1, 2, 3, 4};
double w_array[5] = {1, 2, 3, 4, 5};
network.add_connection_general(0, 1, &f, para, w_array, 5);
......
......@@ -44,11 +44,11 @@ BOOST_AUTO_TEST_SUITE(neuronLinear_test)
NeuronLinear neuron(5.0, 3.0);
//Test of correct output of activation_function_get_derivative method
BOOST_CHECK_EQUAL(3.0, neuron.activation_function_get_derivative());
BOOST_CHECK_EQUAL(3.0, neuron.activation_function_eval_derivative());
//Tests of correct outputs of activation_function_get_partial_derivative method
BOOST_CHECK_EQUAL(1.0, neuron.activation_function_get_partial_derivative(0));
BOOST_CHECK_EQUAL(0.0, neuron.activation_function_get_partial_derivative(1));
BOOST_CHECK_EQUAL(0.0, neuron.activation_function_get_partial_derivative(10000));
BOOST_CHECK_EQUAL(1.0, neuron.activation_function_eval_partial_derivative(0));
BOOST_CHECK_EQUAL(0.0, neuron.activation_function_eval_partial_derivative(1));
BOOST_CHECK_EQUAL(0.0, neuron.activation_function_eval_partial_derivative(10000));
}
BOOST_AUTO_TEST_SUITE_END()
......@@ -44,11 +44,11 @@ BOOST_AUTO_TEST_SUITE(neuronLogistic_test)
NeuronLogistic neuron(3.0, 2.0);
//Test of correct output of activation_function_get_derivative method
BOOST_CHECK_CLOSE(0.0042850850699, neuron.activation_function_get_derivative(), 0.00001);
BOOST_CHECK_CLOSE(0.0042850850699, neuron.activation_function_eval_derivative(), 0.00001);
//Tests of correct outputs of activation_function_get_partial_derivative method
BOOST_CHECK_CLOSE(-0.0068569236644, neuron.activation_function_get_partial_derivative(0), 0.00001);
BOOST_CHECK_CLOSE(-0.0042850850699, neuron.activation_function_get_partial_derivative(1), 0.00001);
BOOST_CHECK_EQUAL(0.0, neuron.activation_function_get_partial_derivative(10000));
BOOST_CHECK_CLOSE(-0.0068569236644, neuron.activation_function_eval_partial_derivative(0), 0.00001);
BOOST_CHECK_CLOSE(-0.0042850850699, neuron.activation_function_eval_partial_derivative(1), 0.00001);
BOOST_CHECK_EQUAL(0.0, neuron.activation_function_eval_partial_derivative(10000));
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
......@@ -42,10 +42,10 @@ BOOST_AUTO_TEST_SUITE(neuronTanh_test)
NeuronTanh neuron(2.0);
//Test of correct output of activation_function_get_derivative method
BOOST_CHECK_CLOSE(-0.0706508248531644, neuron.activation_function_get_derivative(), 0.00001);
BOOST_CHECK_CLOSE(-0.0706508248531644, neuron.activation_function_eval_derivative(), 0.00001);
//Tests of correct outputs of activation_function_get_partial_derivative method
BOOST_CHECK_CLOSE(-0.0706508248531644, neuron.activation_function_get_partial_derivative(0), 0.00001);
BOOST_CHECK_EQUAL(0.0, neuron.activation_function_get_partial_derivative(10000));
BOOST_CHECK_CLOSE(-0.0706508248531644, neuron.activation_function_eval_partial_derivative(0), 0.00001);
BOOST_CHECK_EQUAL(0.0, neuron.activation_function_eval_partial_derivative(10000));
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
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