54 lines
1.5 KiB
C++
54 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <SimpleJSON/SerializableObject.h>
|
|
#include <SimpleJSON/Factory.h>
|
|
|
|
#define NEURAL_NETWORK_REGISTER_ACTIVATION_FUNCTION(name,function) SIMPLEJSON_REGISTER(NeuralNetwork::ActivationFunction::Factory,name,function)
|
|
|
|
#define NEURAL_NETWORK_REGISTER_ACTIVATION_FUNCTION_FINISH(name,function) SIMPLEJSON_REGISTER_FINISH(NeuralNetwork::ActivationFunction::Factory,name,function)
|
|
|
|
namespace NeuralNetwork {
|
|
namespace ActivationFunction {
|
|
|
|
/**
|
|
* @author Tomas Cernik (Tom.Cernik@gmail.com)
|
|
* @brief Abstract class of activation function
|
|
*/
|
|
class ActivationFunction : public SimpleJSON::SerializableObject {
|
|
public:
|
|
|
|
virtual ~ActivationFunction() {}
|
|
|
|
/**
|
|
* @brief Returns derivation of output, it is slower than version with output as it needs to compute output
|
|
* @param input is input of function
|
|
*/
|
|
inline float derivatedOutput(const float &input) const {
|
|
return derivatedOutput(input,operator()(input));
|
|
};
|
|
|
|
/**
|
|
* @brief Returns derivation of output
|
|
* @param input is input of function
|
|
* @param output is output of function
|
|
* @see derivatedOutput
|
|
*/
|
|
virtual float derivatedOutput(const float &input, const float &output) const=0;
|
|
|
|
/**
|
|
* @brief Returns value of output
|
|
* @param x is input of function
|
|
*/
|
|
virtual float operator()(const float &x) const=0;
|
|
|
|
/**
|
|
* @brief Function returns clone of object
|
|
*/
|
|
virtual ActivationFunction* clone() const = 0;
|
|
|
|
};
|
|
|
|
typedef SimpleJSON::Factory<ActivationFunction> Factory;
|
|
|
|
}
|
|
} |