Skip to content
Snippets Groups Projects
NeuronLogistic_test.cpp 1.83 KiB
Newer Older
  • Learn to ignore specific revisions
  • David Vojtek's avatar
    David Vojtek committed
    /**
     * DESCRIPTION OF THE CLASS
     *
     * @author David Vojtek
     * @date 2018
     */
    
    #define BOOST_TEST_NO_MAIN
    
    #include <boost/test/unit_test.hpp>
    #include "../Neuron/NeuronLogistic.h"
    
    David Vojtek's avatar
    David Vojtek committed
    /**
     * 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
         */
    
    David Vojtek's avatar
    David Vojtek committed
        BOOST_AUTO_TEST_CASE(neuronLogistic_construction__test) {
            NeuronLogistic neuron(1.745, 784.4547);
    
            //Test of correct value of first activation function parameter
    
    David Vojtek's avatar
    David Vojtek committed
            BOOST_CHECK_EQUAL(neuron.activation_function_get_parameter(0), 1.745);
    
            //Test of correct value of second activation function parameter
    
    David Vojtek's avatar
    David Vojtek committed
            BOOST_CHECK_EQUAL(neuron.activation_function_get_parameter(1), 784.4547);
        }
    
    
        /**
         * Test of activate method
         */
    
    David Vojtek's avatar
    David Vojtek committed
        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.0016937944, neuron.get_state(), 0.00001);
    
    David Vojtek's avatar
    David Vojtek committed
        }
    
    
        /**
         * Test of derivative methods
         */
        BOOST_AUTO_TEST_CASE(neuronLogistic_derivative_test) {
    
    David Vojtek's avatar
    David Vojtek committed
            NeuronLogistic neuron(3.0, 2.0);
    
    
            //Test of correct output of activation_function_get_derivative method
    
    Michal Kravcenko's avatar
    Michal Kravcenko committed
            BOOST_CHECK_CLOSE(0.0042850850699, neuron.activation_function_eval_derivative(), 0.00001);
    
            //Tests of correct outputs of activation_function_get_partial_derivative method
    
    Michal Kravcenko's avatar
    Michal Kravcenko committed
            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);
    
    Martin Beseda's avatar
    Martin Beseda committed
            BOOST_CHECK_EQUAL(0.0, neuron.activation_function_eval_partial_derivative(10000));
    
    David Vojtek's avatar
    David Vojtek committed
    
    
    Martin Beseda's avatar
    Martin Beseda committed
    BOOST_AUTO_TEST_SUITE_END()