#include <boost/serialization/export.hpp> #include <iostream> #include "NeuronLinearSaturated.h" #include "NeuronBinary.h" #include "NeuronSerialization.h" #include "NeuronLinearSaturatedSerialization.h" #include "exceptions.h" BOOST_CLASS_EXPORT_IMPLEMENT(lib4neuro::NeuronLinearSaturated); namespace lib4neuro { NeuronLinearSaturated::NeuronLinearSaturated(double saturation_point) { this->saturation_point = saturation_point; } double NeuronLinearSaturated::activate(double x, double b) { if (x + b < 0) { return 0.0; } else if (x + b > this->saturation_point) { return this->saturation_point; } else { return x + b; } } double NeuronLinearSaturated::activation_function_eval_derivative_bias(double x, double b) { // f'(0) = 0 for the purposes of training if (x + b < 0) { return 0.0; } else if (x + b > this->saturation_point) { return 0.0; } else { return 1.0; } } double NeuronLinearSaturated::activation_function_eval_derivative(double x, double b) { // f'(0) = 0 for the purposes of training if (x + b < 0) { return 0.0; } else if (x + b > this->saturation_point) { return 0.0; } else { return 1.0; } } Neuron* NeuronLinearSaturated::get_derivative() { THROW_NOT_IMPLEMENTED_ERROR("The derivative of Linear Saturated neuron is not implemented yet"); } }