Commit e75c6464 authored by David Vojtek's avatar David Vojtek

new DataSet unit test + tests comments

parent 52ffe1d1
......@@ -72,6 +72,9 @@ target_link_libraries(neural_network_test boost_unit_test neuron)
add_executable(connection_weight_identity_test tests/ConnectionWeightIdentity_test.cpp)
target_link_libraries(connection_weight_identity_test boost_unit_test neuron)
add_executable(dataset_test tests/DataSet_test.cpp)
target_link_libraries(dataset_test boost_unit_test data_set)
add_executable(particle_swarm_test tests/ParticleSwarm_test.cpp)
target_link_libraries(particle_swarm_test boost_unit_test neuron particle_swarm)
......
......@@ -8,26 +8,33 @@
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#include "../NetConnection/ConnectionWeightIdentity.h"
/**
* Boost testing suite for testing ConnectionWeightIdentity.h
*/
BOOST_AUTO_TEST_SUITE(ConnectionWeightIdentity_test)
BOOST_AUTO_TEST_CASE(ConnectionWeightIdentity_construction_test){
std::vector<double> weight_array = {1,2,3,4,5};
BOOST_CHECK_NO_THROW(ConnectionWeightIdentity CWI(&weight_array));
}
BOOST_AUTO_TEST_CASE(ConnectionWeightIdentity_eval_test){
std::vector<double> weight_array = {1,2,3,4,5};
ConnectionWeightIdentity CWI(&weight_array);
int para[5]={3,1,2,3,4};
CWI.SetParamIndices(para);
BOOST_CHECK_EQUAL(4,CWI.eval());
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(ConnectionWeightIdentity_test)
/**
* Test of correct construction of ConnectionWeightIdentity
*/
BOOST_AUTO_TEST_CASE(ConnectionWeightIdentity_construction_test) {
std::vector<double> weight_array = {1, 2, 3, 4, 5};
//Test of none exception when creation new instance of ConnectionWeightIdentity
BOOST_CHECK_NO_THROW(ConnectionWeightIdentity CWI(&weight_array));
}
/**
* Test of eval method
*/
BOOST_AUTO_TEST_CASE(ConnectionWeightIdentity_eval_test) {
std::vector<double> weight_array = {1, 2, 3, 4, 5};
ConnectionWeightIdentity CWI(&weight_array);
int para[5] = {3, 1, 2, 3, 4};
CWI.SetParamIndices(para);
//Test of correct output of eval method
BOOST_CHECK_EQUAL(4, CWI.eval());
}
BOOST_AUTO_TEST_SUITE_END()
......@@ -8,24 +8,28 @@
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#include "../NetConnection/ConnectionWeight.h"
/**
* Boost testing suite for testing ConnectionWeight.h
* TODO
*/
BOOST_AUTO_TEST_SUITE(ConnectionWeight_test)
/**
* Test of construction of ConnectionWeight
*/
BOOST_AUTO_TEST_CASE(ConnectionWeight_construction__test) {
std::vector<double> * w_array = nullptr ;
std::function<double(double *, int*, int)> *f= nullptr;
BOOST_CHECK_NO_THROW( ConnectionWeight conn(2, w_array, f ));
BOOST_CHECK_NO_THROW( ConnectionWeight conn);
//Tests of no exception when, create new instance
BOOST_CHECK_NO_THROW( ConnectionWeight conn(2, w_array, f ));
BOOST_CHECK_NO_THROW( ConnectionWeight conn);
}
/**
* Test of setParamIndices and SetParamIndex methods
*/
BOOST_AUTO_TEST_CASE(ConnectionWeight_param_test){
std::vector<double> w_array= {0,1,2,3,4} ;
std::function<double(double *, int*, int)> f= [](double * weight_array, int * index_array, int n_params){
......@@ -34,26 +38,22 @@ BOOST_AUTO_TEST_SUITE(ConnectionWeight_test)
return (a + 1.5 * b);
};
ConnectionWeight conn(5, &w_array, &f );
ConnectionWeight connbad(7, &w_array, &f );
int para[5]={0,1,2,3,4};
//Test of no exception when call SetParamIndices method on instance created with with correct parameters
BOOST_CHECK_NO_THROW(conn.SetParamIndices(para));
//Test of no exception when call SetParamIndex method on instance created with with correct parameters
BOOST_CHECK_NO_THROW(conn.SetParamIndex(2,2));
}
BOOST_AUTO_TEST_CASE(ConnectionWeight_param_out_of_range_test){
std::vector<double> w_array= {0,1,2,3,4} ;
std::function<double(double *, int*, int)> f= [](double * weight_array, int * index_array, int n_params){
double a = 5;
double b = 4;
return (a + 1.5 * b);
};
ConnectionWeight conn(7, &w_array, &f );
int para[5]={0,1,2,3,4};
//para out of range
BOOST_CHECK_THROW(conn.SetParamIndices(para), std::out_of_range);
//paramIndex out of range
BOOST_CHECK_THROW(conn.SetParamIndex(2,8), std::out_of_range);
//Test of expected exception out_of_range when call SetParamIndices method on instance created with with incorrect parameters
BOOST_CHECK_THROW(connbad.SetParamIndices(para), std::out_of_range);
//Test of expected exception out_of_range when call SetParamIndex method on instance created with incorrect parameters
BOOST_CHECK_THROW(connbad.SetParamIndex(2,8), std::out_of_range);
}
/**
* Test of eval method
*/
BOOST_AUTO_TEST_CASE(ConnectionWeight_eval__test) {
std::vector<double> w_array= {2,3,4,5,6} ;
std::function<double(double *, int*, int)> f= [](double * weight_array, int * index_array, int n_params){
......@@ -64,9 +64,14 @@ BOOST_AUTO_TEST_SUITE(ConnectionWeight_test)
ConnectionWeight conn(5, &w_array, &f );
int para[5]={4,8,2,3,4};
conn.SetParamIndices(para);
//Test of correct output after calling eval() method
BOOST_CHECK_EQUAL(6.5, conn.eval());
}
/**
* Test of adjust_weights method
*/
BOOST_AUTO_TEST_CASE(ConnectionWeight_weight_adjustment_test) {
std::vector<double> w_array= {2,3,4,5,6} ;
double w_array2[5] = {1,2,3,4,5};
......@@ -79,9 +84,14 @@ BOOST_AUTO_TEST_SUITE(ConnectionWeight_test)
int para[5]={0,1,2,3,4};
conn.SetParamIndices(para);
conn.adjust_weights(w_array2);
//Test of correct eval output after adjusting weights
BOOST_CHECK_EQUAL(10.5, conn.eval());
}
/**
* Test of set_weights method
*/
BOOST_AUTO_TEST_CASE(ConnectionWeight_weight_set_test) {
std::vector<double> w_array= {2,3,4,5,6} ;
double w_array2[5] = {1,2,3,4,5};
......@@ -94,6 +104,8 @@ BOOST_AUTO_TEST_SUITE(ConnectionWeight_test)
int para[5]={0,1,2,3,4};
conn.SetParamIndices(para);
conn.set_weights(w_array2);
//Test of correct eval output after setting new weights
BOOST_CHECK_EQUAL(4, conn.eval());
}
......
......@@ -20,6 +20,9 @@
BOOST_AUTO_TEST_SUITE(Connection_test)
/**
* Test of constructor of Connection
*/
BOOST_AUTO_TEST_CASE(Connection_construction__test) {
Neuron* neuron1 = new NeuronLinear(2,3);
......@@ -37,10 +40,15 @@ BOOST_AUTO_TEST_SUITE(Connection_test)
conn->SetParamIndices(para);
Connection connection(neuron1, neuron2, conn);
//Test of correct input neuron
BOOST_CHECK_EQUAL(neuron1, connection.get_neuron_in());
//Test of correct output neuron
BOOST_CHECK_EQUAL(neuron2, connection.get_neuron_out());
}
/**
* Test of pass_signal method
*/
BOOST_AUTO_TEST_CASE(Connection_pass_signal_test) {
Neuron* neuron1 = new NeuronLinear(2,3);
......@@ -60,9 +68,11 @@ BOOST_AUTO_TEST_SUITE(Connection_test)
neuron1->activate();
neuron2->activate();
// test of neuron state before passing signal
BOOST_CHECK_EQUAL(4, neuron2->get_state());
connection.pass_signal();
neuron2->activate();
// test of neuron state after passing signal
BOOST_CHECK_EQUAL(69, neuron2->get_state());
}
......
/**
* DESCRIPTION OF THE CLASS
*
* @author David Vojtek
* @date 2018
*/
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#include <boost/test/output_test_stream.hpp>
#include <iostream>
#include "../DataSet/DataSet.h"
//#include <boost/filesystem.hpp>
/**
* Boost testing suite for testing DataSet.h
*/
BOOST_AUTO_TEST_SUITE(DataSet_test)
struct cout_redirect {
cout_redirect(std::streambuf *new_buffer)
: old(std::cout.rdbuf(new_buffer)) {}
~cout_redirect() {
std::cout.rdbuf(old);
}
private:
std::streambuf *old;
};
/**
* Test of DataSet constructor with filepath parameter
*/
BOOST_AUTO_TEST_CASE(DataSet_construction_from_file_test) {
//test of exception with non-existing file path
BOOST_CHECK_THROW(DataSet dataSet("file unknown"), std::runtime_error);
}
/**
* Test of DataSet constructor with vector parameter
*/
BOOST_AUTO_TEST_CASE(DataSet_construction_from_vector_test) {
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_vec;
std::vector<double> inp, out;
for (int i = 0; i < 3; i++) {
inp.push_back(i);
out.push_back(i + 4);
}
data_vec.emplace_back(std::make_pair(inp, out));
DataSet dataSet(&data_vec);
//test of no exception when create object DataSet
BOOST_CHECK_NO_THROW(DataSet dataSet(&data_vec));
}
/**
* Test of get_data method
*/
BOOST_AUTO_TEST_CASE(DataSet_get_data_test) {
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_vec;
std::vector<double> inp, out;
for (int i = 0; i < 3; i++) {
inp.push_back(i);
out.push_back(i + 4);
}
data_vec.emplace_back(std::make_pair(inp, out));
DataSet dataSet(&data_vec);
//test of equal data
BOOST_CHECK_EQUAL(&data_vec, dataSet.get_data());
}
/**
* Test of add_data_pair method
*/
BOOST_AUTO_TEST_CASE(DataSet_add_daata_pair_test) {
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_vec;
std::vector<double> inp, out;
for (int i = 0; i < 3; i++) {
inp.push_back(i);
out.push_back(i + 4);
}
data_vec.emplace_back(std::make_pair(inp, out));
DataSet dataSet(&data_vec);
inp.clear();
out.clear();
inp.push_back(10);
out.push_back(14);
dataSet.add_data_pair(inp, out);
// Test of correct add of input
BOOST_CHECK_EQUAL(10, dataSet.get_data()->at(0).first.at(3));
// Test of correct add of output
BOOST_CHECK_EQUAL(14, dataSet.get_data()->at(0).second.at(3));
}
/**
* Test of get_input_dim and get_output_dim methods
*/
BOOST_AUTO_TEST_CASE(DataSet_dimension_test) {
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_vec;
std::vector<double> inp, out;
for (int i = 0; i < 3; i++) {
inp.push_back(i);
out.push_back(i + 4);
}
data_vec.emplace_back(std::make_pair(inp, out));
DataSet dataSet(&data_vec);
//Test of correct input dimension
BOOST_CHECK_EQUAL(1, dataSet.get_input_dim());
//Test of correct output dimension
BOOST_CHECK_EQUAL(1, dataSet.get_output_dim());
}
/**
* Test of get_n_elements method
*/
BOOST_AUTO_TEST_CASE(DataSet_get_number_of_elements_test) {
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_vec;
std::vector<double> inp, out;
for (int i = 0; i < 3; i++) {
inp.push_back(i);
out.push_back(i + 4);
}
data_vec.emplace_back(std::make_pair(inp, out));
DataSet dataSet(&data_vec);
//Test of correct number of elements
BOOST_CHECK_EQUAL(3, dataSet.get_n_elements());
}
/**
* Test of print_data method
*/
BOOST_AUTO_TEST_CASE(DataSet_print_data_test) {
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_vec;
std::vector<double> inp, out;
for (int i = 0; i < 1; i++) {
inp.push_back(i);
out.push_back(i + 4);
}
data_vec.emplace_back(std::make_pair(inp, out));
DataSet dataSet(&data_vec);
boost::test_tools::output_test_stream output;
{
cout_redirect guard(output.rdbuf());
dataSet.print_data();
}
//Test of correct print of DataSet
BOOST_CHECK(output.is_equal("0 -> 4 "));
}
/**
* Test of store_text method
*/
BOOST_AUTO_TEST_CASE(DataSet_store_text_test) {
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_vec;
std::vector<double> inp, out;
for (int i = 0; i < 1; i++) {
inp.push_back(i);
out.push_back(i + 4);
}
data_vec.emplace_back(std::make_pair(inp, out));
DataSet dataSet(&data_vec);
dataSet.store_text("testDataSet");
//Test of correct file creations
//BOOST_CHECK(boost::filesystem::exists( "testDataSet" ));
DataSet newDataSet("testDataSet");
//Test of correct number of element from dataSet from file
BOOST_CHECK_EQUAL(3, newDataSet.get_n_elements());
// removing of created file
remove("testDataSet");
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
......@@ -8,65 +8,79 @@
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#include "../Network/NeuralNetwork.h"
#include "../Neuron/NeuronLinear.h"
/**
* Boost testing suite for testing NeuralNetwork.h
*/
BOOST_AUTO_TEST_SUITE(NeuralNetwork_test)
BOOST_AUTO_TEST_CASE(NeuralNetwork_constuction_test){
/**
* Test of creating new instance of NeuralNetwork
*/
BOOST_AUTO_TEST_CASE(NeuralNetwork_constuction_test) {
//Test of none exception raise when creating new instance of NeuralNewtwork
BOOST_CHECK_NO_THROW(NeuralNetwork network);
}
BOOST_AUTO_TEST_CASE(NeuralNetwork_add_neuron_test){
Neuron* n1 = new NeuronLinear(1,1);
Neuron* n2 = new NeuronLinear(2,2);
Neuron* n3 = new NeuronLinear(3,3);
Neuron* n4 = new NeuronLinear(4,4);
/**
* Test of add_neuron method
*/
BOOST_AUTO_TEST_CASE(NeuralNetwork_add_neuron_test) {
Neuron *n1 = new NeuronLinear(1, 1);
Neuron *n2 = new NeuronLinear(2, 2);
NeuralNetwork network;
BOOST_CHECK_EQUAL(0,network.add_neuron(n1));
BOOST_CHECK_EQUAL(1,network.add_neuron(n2));
BOOST_CHECK_EQUAL(2,network.add_neuron(n3));
BOOST_CHECK_EQUAL(3,network.add_neuron(n4));
//Tests of correct neuron indexs when add_neuron
BOOST_CHECK_EQUAL(0, network.add_neuron(n1));
BOOST_CHECK_EQUAL(1, network.add_neuron(n2));
}
BOOST_AUTO_TEST_CASE(NeuralNetwork_add_connection_simple_test){
Neuron* n1 = new NeuronLinear(1,1);
Neuron* n2 = new NeuronLinear(2,2);
/**
* Test of add_connection_simple method
*/
BOOST_AUTO_TEST_CASE(NeuralNetwork_add_connection_simple_test) {
Neuron *n1 = new NeuronLinear(1, 1);
Neuron *n2 = new NeuronLinear(2, 2);
NeuralNetwork network;
network.add_neuron(n1);
network.add_neuron(n2);
network.add_connection_simple(0,1,0,2.5);
network.add_connection_simple(0, 1, 0, 2.5);
//Tests of correct connection number with affected neurons
BOOST_CHECK_EQUAL(1, n1->get_connections_out()->size());
BOOST_CHECK_EQUAL(1, n2->get_connections_in()->size());
BOOST_CHECK_THROW(network.add_connection_simple(2,0,0,0), std::out_of_range);
BOOST_CHECK_THROW(network.add_connection_simple(0,2,0,0), std::out_of_range);
BOOST_CHECK_THROW(network.add_connection_simple(0,1,-1,0), std::out_of_range);
//Tests of raising out_of_range exception when calling add_connection_simple with not valid parameters
BOOST_CHECK_THROW(network.add_connection_simple(2, 0, 0, 0), std::out_of_range);
BOOST_CHECK_THROW(network.add_connection_simple(0, 2, 0, 0), std::out_of_range);
BOOST_CHECK_THROW(network.add_connection_simple(0, 1, -1, 0), std::out_of_range);
}
BOOST_AUTO_TEST_CASE(NeuralNetwork_add_connection_general_test){
/**
* Test of add_connection_general method
*/
BOOST_AUTO_TEST_CASE(NeuralNetwork_add_connection_general_test) {
NeuralNetwork network;
Neuron* n1 = new NeuronLinear(1,1);
Neuron* n2 = new NeuronLinear(2,2);
Neuron *n1 = new NeuronLinear(1, 1);
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 *, int *, int)> f = [](double *weight_array, int *index_array, int 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};
double w_array[5] = {1,2,3,4,5};
int 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);
network.add_connection_general(0, 1, &f, para, w_array, 5);
//Tests of correct connection number with affected neurons
BOOST_CHECK_EQUAL(1, n1->get_connections_out()->size());
BOOST_CHECK_EQUAL(1, n2->get_connections_in()->size());
BOOST_CHECK_THROW(network.add_connection_general(2,1, &f, para, w_array, 5), std::out_of_range);
BOOST_CHECK_THROW(network.add_connection_general(0,2, &f, para, w_array, 5), std::out_of_range);
//Tests of raising out_of_range exception when calling add_connection_general with not valid parameters
BOOST_CHECK_THROW(network.add_connection_general(2, 1, &f, para, w_array, 5), std::out_of_range);
BOOST_CHECK_THROW(network.add_connection_general(0, 2, &f, para, w_array, 5), std::out_of_range);
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
......@@ -8,27 +8,35 @@
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#include "../Neuron/NeuronBinary.h"
/**
* Boost testing suite for testing NeuronBinary.h
* doesn't test inherited methods
*/
BOOST_AUTO_TEST_SUITE(neuronBinary_test)
/**
* Test of creating new instance of NeuronBinary
*/
BOOST_AUTO_TEST_CASE(neuronLinear_construction__test) {
NeuronBinary neuron(1.745);
//Test of correct value of activation function parameter
BOOST_CHECK_EQUAL(neuron.activation_function_get_parameter(0), 1.745);
}
/**
* Test of activate method
*/
BOOST_AUTO_TEST_CASE(neuronLinear_activate__test) {
NeuronBinary neuron(1.75);
neuron.activate();
//Test of correct state neuron
BOOST_CHECK_EQUAL(0.0, neuron.get_state());
neuron.set_potential(1.76);
neuron.activate();
//Another test of correct state of neuron
BOOST_CHECK_EQUAL(1.0, neuron.get_state());
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
......@@ -8,29 +8,44 @@
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#include "../Neuron/NeuronLinear.h"
/**
* Boost testing suite for testing NeuronLinear.h
* doesn't test inherited methods
*/
BOOST_AUTO_TEST_SUITE(neuronLinear_test)
/**
* Test of creating new instance of NeuronLinear
*/
BOOST_AUTO_TEST_CASE(neuronLinear_construction__test) {
NeuronLinear neuron(1.745, 784.4547);
//Test of correct value of first activation function parameter
BOOST_CHECK_EQUAL(neuron.activation_function_get_parameter(0), 1.745);
//Test of correct value of second activation function parameter
BOOST_CHECK_EQUAL(neuron.activation_function_get_parameter(1), 784.4547);
}
/**
* Test of activate method
*/
BOOST_AUTO_TEST_CASE(neuronLinear_activate__test) {
NeuronLinear neuron(5.0, 1.0);
neuron.activate();
//Test of correct state after activate neuron
BOOST_CHECK_EQUAL(5.0, neuron.get_state());
}
/**
* Test of derivative methods
*/
BOOST_AUTO_TEST_CASE(neuronLinear_derivative_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());
//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));
......
......@@ -8,34 +8,47 @@
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#include "../Neuron/NeuronLogistic.h"
/**
* Boost testing suite for testing NeuronLogistic.h
* doesn't test inherited methods
*/
BOOST_AUTO_TEST_SUITE(neuronLogistic_test)
/**
* Test of creating new instance of NeuronLogistic
*/
BOOST_AUTO_TEST_CASE(neuronLogistic_construction__test) {
NeuronLogistic neuron(1.745, 784.4547);
//Test of correct value of first activation function parameter
BOOST_CHECK_EQUAL(neuron.activation_function_get_parameter(0), 1.745);
//Test of correct value of second activation function parameter
BOOST_CHECK_EQUAL(neuron.activation_function_get_parameter(1), 784.4547);
}
/**
* Test of activate method
*/
BOOST_AUTO_TEST_CASE(neuronLogistic_activate__test) {
NeuronLogistic neuron(3.0, 2.0);
neuron.activate();
//Test of correct state after activate neuron
BOOST_CHECK_CLOSE(0.0022492134466, neuron.get_state(), 0.00001);
}
BOOST_AUTO_TEST_CASE(neuronLogistic_derivative_test){
/**
* Test of derivative methods
*/
BOOST_AUTO_TEST_CASE(neuronLogistic_derivative_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);
//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_AUTO_TEST_SUITE_END()
\ No newline at end of file
......@@ -16,24 +16,36 @@
*/
BOOST_AUTO_TEST_SUITE(neuronTanh_test)
/**
* Test of creating new instance of NeuronTanh
*/
BOOST_AUTO_TEST_CASE(neuronTanh_construction__test) {
NeuronTanh neuron(1.745);
//Test of correct value of activation function parameter
BOOST_CHECK_EQUAL(neuron.activation_function_get_parameter(0), 1.745);
}
/**
* Test of activate method
*/
BOOST_AUTO_TEST_CASE(neuronTanh_activate__test) {
NeuronTanh neuron(2.0);
neuron.activate();
//Test of correct state after activate neuron
BOOST_CHECK_CLOSE(-0.96402758007581, neuron.get_state(), 0.00001);
}
BOOST_AUTO_TEST_CASE(neuronTanh_derivative_test){
/**
* Test of derivative methods
*/
BOOST_AUTO_TEST_CASE(neuronTanh_derivative_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);
//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_AUTO_TEST_SUITE_END()
\ No newline at end of file
......@@ -22,16 +22,21 @@ return 0;
BOOST_AUTO_TEST_SUITE(ParticleSwarm_test)
/**
* TODO
*/