Skip to content
Snippets Groups Projects
NeuronFilter.cpp 1.07 KiB
Newer Older

#include <boost/serialization/export.hpp>

#include "NeuronRectifier.h"
#include "NeuronBinary.h"
#include "Neuron.h"
#include "NeuronSerialization.h"
#include "NeuronFilterSerialization.h"
#include "exceptions.h"

BOOST_CLASS_EXPORT_IMPLEMENT(lib4neuro::NeuronFilter);

namespace lib4neuro {
    NeuronFilter::NeuronFilter(double b) {
			this->bias = b;
		}

    double NeuronFilter::activate(double x,
                                     double b) {
        return ((x + this->bias) > 0) ? x : 0.0;
    }

    double NeuronFilter::activation_function_eval_derivative_bias(double x,
                                                                		 double b) {
        return 0.0;
    }

    double NeuronFilter::activation_function_eval_derivative(double x,
                                                                double b) {
        // f'(-bias) = 0 for the purposes of training
        return ((x + this->bias) > 0) ? 1.0 : 0.0;
    }

    Neuron* NeuronFilter::get_derivative() {
		THROW_NOT_IMPLEMENTED_ERROR("The derivative of Filter neuron is not implemented yet");