Commit a0d606c9 authored by Martin Beseda's avatar Martin Beseda

ENH: Moved derivative methods to IDifferentiable class-interface, so that not...

ENH: Moved derivative methods to IDifferentiable class-interface, so that not all activation classes have to implement them now.
parent 19846f8b
......@@ -160,21 +160,6 @@ public:
*/
virtual int activation_function_get_n_parameters();
/**
* Calculates the partial derivative of the activation function
* with respect to the parameter and the current potential
* @param[in] param_idx Index of the parameter to calculate derivative of
* @return Partial derivative of the activation function according to the
* 'param_idx'-th parameter
*/
virtual double activation_function_get_partial_derivative(int param_idx) = 0;
/**
* Calculates the derivative with respect to the argument, ie the 'potential'
* @return f'(x), where 'f(x)' is the activation function and 'x' = 'potential'
*/
virtual double activation_function_get_derivative( ) = 0;
/**
* Adjusts the parameter with index 'param_idx' of the activation function
* by the value prescribed by 'value'
......@@ -225,4 +210,25 @@ public:
}; /* end of Neuron class */
#endif /* NEURON_H_ */
\ No newline at end of file
/**
* Class serving as an interface providing 'activation_function_get_partial_derivative'
* and 'activation_function_get_derivative' methods.
*/
class IDifferentiable {
/**
* Calculates the partial derivative of the activation function
* with respect to the parameter and the current potential
* @param[in] param_idx Index of the parameter to calculate derivative of
* @return Partial derivative of the activation function according to the
* 'param_idx'-th parameter
*/
virtual double activation_function_get_partial_derivative(int param_idx) = 0;
/**
* Calculates the derivative with respect to the argument, ie the 'potential'
* @return f'(x), where 'f(x)' is the activation function and 'x' = 'potential'
*/
virtual double activation_function_get_derivative( ) = 0;
}; /* end of IDifferentiable class */
#endif /* NEURON_H_ */
\ No newline at end of file
......@@ -16,7 +16,7 @@
* Linear neuron class - uses activation function in the form f(x)=a*x + b,
* 'x' being the neuron's potential
*/
class NeuronLinear:public Neuron {
class NeuronLinear:public Neuron, public IDifferentiable {
friend class boost::serialization::access;
protected:
......
......@@ -14,7 +14,7 @@
#include "Neuron.h"
#include "../constants.h"
class NeuronLogistic:public Neuron {
class NeuronLogistic:public Neuron, public IDifferentiable {
friend class boost::serialization::access;
protected:
......
......@@ -14,7 +14,7 @@
#include "Neuron.h"
#include "../constants.h"
class NeuronTanh:public Neuron {
class NeuronTanh:public Neuron, public IDifferentiable {
friend class boost::serialization::access;
protected:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment