Commit 6d7ca604 authored by Michal Kravcenko's avatar Michal Kravcenko

added child classes of the Neuron class

parent 1c5d9cea
......@@ -5,31 +5,32 @@
<usages-collector id="statistics.file.extensions.open">
<counts>
<entry key="Makefile" value="1" />
<entry key="cpp" value="1" />
<entry key="cpp" value="8" />
<entry key="f90" value="1" />
<entry key="h" value="1" />
<entry key="h" value="5" />
<entry key="txt" value="2" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.open">
<counts>
<entry key="CMakeLists.txt" value="2" />
<entry key="ObjectiveC" value="2" />
<entry key="ObjectiveC" value="13" />
<entry key="PLAIN_TEXT" value="2" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.edit">
<counts>
<entry key="cpp" value="478" />
<entry key="h" value="1861" />
<entry key="txt" value="74" />
<entry key="cpp" value="731" />
<entry key="h" value="2161" />
<entry key="txt" value="208" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="CMakeLists.txt" value="74" />
<entry key="Doxygen file" value="27" />
<entry key="ObjectiveC" value="2312" />
<entry key="CMakeLists.txt" value="109" />
<entry key="Doxygen file" value="31" />
<entry key="ObjectiveC" value="2861" />
<entry key="PLAIN_TEXT" value="99" />
</counts>
</usages-collector>
</session>
......
add_library(${SRC_DIR} neuron.cpp)
add_library(neuron SHARED Neuron/neuron.cpp Neuron/neuron.h Neuron/NeuronBinary.cpp Neuron/NeuronBinary.h Neuron/NeuronLinear.cpp Neuron/NeuronLinear.h Neuron/NeuronLogistic.cpp Neuron/NeuronLogistic.h Neuron/NeuronTanh.cpp Neuron/NeuronTanh.h)
//
// Created by fluffymoo on 11.6.18.
//
#include "NeuronBinary.h"
NeuronBinary::NeuronBinary(double threshold) {
this->activation_function_parameters = new double[1];
this->activation_function_parameters[0] = threshold;
}
void NeuronBinary::activate() {
if(this->potential >= this->activation_function_parameters[0]){
this->state = 1.0;
}
else{
this->state = 0.0;
}
}
//
// Created by fluffymoo on 11.6.18.
//
#ifndef INC_4NEURO_NEURONBINARY_H
#define INC_4NEURO_NEURONBINARY_H
#include "neuron.h"
/**
* Binary neuron class - uses unit-step as the activation function
*/
class NeuronBinary:Neuron {
private:
public:
/**
* Default constructor for the binary Neuron
* @param threshold Denotes when the neuron is activated
* When neuron potential exceeds 'threshold' value it becomes excited
*/
explicit NeuronBinary(double threshold);
/**
* Performs the activation function and stores the result into the 'state' property
*/
void activate() override;
};
#endif //INC_4NEURO_NEURONBINARY_H
/*
!-----------------------!----------------------------------------------------------------------
! class binary_neuron_t !
!-----------------------!
!> Binary neuron class - uses unit-step as the activation function
type, extends(neuron_t) :: binary_neuron_t
private
real(kind=real_4neuro) :: threshold !< When neuron potential exceeds this value, neuron becomes excited
contains
!> Activation function - transforms potential into the output state value
!! AND assigns it into the 'state' component
!!
!! Unit-step function - (returns 1 for potential > threshold, otherwise returns 0)
procedure, private :: activate => unit_step_activate_impl
end type binary_neuron_t
interface binary_neuron_t
!> Non-parametric constructor of binary_neuron_t class (threshold
!! will be initialized by a random number from Gaussian distribution)
!! @return An instance of the class binary_neuron_t
module procedure :: new_binary_neuron
!> Parametric constructor of binary_neuron_t class
!! @param[in] threshold Threshold for the unit-step activation function
!! @return An instance of the class binary_neuron_t
module procedure :: new_binary_neuron_1
end interface binary_neuron_t
*/
\ No newline at end of file
//
// Created by fluffymoo on 11.6.18.
//
#include "NeuronLinear.h"
//
// Created by fluffymoo on 11.6.18.
//
#ifndef INC_4NEURO_NEURONLINEAR_H
#define INC_4NEURO_NEURONLINEAR_H
class NeuronLinear {
};
#endif //INC_4NEURO_NEURONLINEAR_H
/*
!-----------------------!----------------------------------------------------------------------
! class linear_neuron_t !
!-----------------------!
!> Linear neuron class - uses activation function in the form f(x)=a*x + b,
!! 'x' being the neuron's potential
type, extends(neuron_t) :: linear_neuron_t
private
!! Coefficients for the linear activation function in format 'f(x)=a*x + b'
real(kind=real_4neuro) :: a_coef !< The coefficient 'a' in the activation function f(x)=a*x + b
real(kind=real_4neuro) :: b_coef !< The coefficient 'b' in the activation function f(x)=a*x + b
contains
!> Activation function - f(x)=a*x + b
procedure, private :: activate => identity_potential_activate_impl
end type linear_neuron_t
interface linear_neuron_t
!> Non-parametric constructor of linear_neuron_t class - a coef. is 1, b coef. is 0
!! @return An instance of the class linear_neuron_t
module procedure :: new_linear_neuron
!> Constructor of linear_neuron_t class
!! @param[in] a_coef a coef. of the linear activation function
!! @param[in] b_coef b coef. of the linear activation fucntion
!! @return An instance of the class linear_neuron_t
module procedure :: new_linear_neuron_2
end interface linear_neuron_t
*/
\ No newline at end of file
//
// Created by fluffymoo on 11.6.18.
//
#include "NeuronLogistic.h"
//
// Created by fluffymoo on 11.6.18.
//
#ifndef INC_4NEURO_NEURONLOGISTIC_H
#define INC_4NEURO_NEURONLOGISTIC_H
class NeuronLogistic {
};
#endif //INC_4NEURO_NEURONLOGISTIC_H
/*
!-------------------------!--------------------------------------------------------------------
! class logistic_neuron_t !
!-------------------------!
!> Logistic neuron class - uses generalised logistic function as an activation function
!! in the form f(x) = (1 + e^(-x))^(-alpha),
!! 'x' being the neuron potential here
type, extends(neuron_t) :: logistic_neuron_t
private
real(kind=real_4neuro) :: alpha_coef !< The alpha coefficient used in the activation function
contains
!> Activation function - generalised logistic f.
procedure, private :: activate => logistic_activate_impl
end type logistic_neuron_t
interface logistic_neuron_t
!> Non-parametric constructor of logistic_neuron_t class
!! Alpha coefficient is set to 1
!! @return An instance of the class logistic_neuron_t
module procedure :: new_logistic_neuron
!> Constructor of the logistic_neuron_t class
!! @param[in] alpha_coef Alpha coefficient in the logistic activation function
!! @return An instance of the class logistic_neuron_t
module procedure :: new_logistic_neuron_1
end interface logistic_neuron_t
*/
\ No newline at end of file
//
// Created by fluffymoo on 11.6.18.
//
#include "NeuronTanh.h"
//
// Created by fluffymoo on 11.6.18.
//
#ifndef INC_4NEURO_NEURONTANH_H
#define INC_4NEURO_NEURONTANH_H
class NeuronTanh {
};
#endif //INC_4NEURO_NEURONTANH_H
/*
!---------------------!------------------------------------------------------------------------
! class tanh_neuron_t !
!---------------------!
!> Hyperbolic tangent neuron class - uses f(x) = (e^x - e^(-x))/(e^x + e^(-x)) as
!! an activation function, 'x' being the neuron potential.
type, extends(neuron_t) :: tanh_neuron_t
contains
!> Activation function - hyperbolic tangent
procedure, private :: activate => hyperbolic_tangent_activate_impl
end type tanh_neuron_t
interface tanh_neuron_t
!> Constructor for an instance of the class tanh_neuron_t
module procedure :: new_tanh_neuron
end interface tanh_neuron_t
!> Arcus tangents neuron class - uses f(x)=tan^(-1)(x) as an
!! activation function, 'x' being the neuron potential
type, extends(neuron_t) :: arctan_neuron_t
contains
!> Activation function - arcus tangens
procedure, private :: activate => arcus_tangens_activate_impl
end type arctan_neuron_t
interface arctan_neuron_t
!> Constructor for an instance of the class arctan_neuron_t
module procedure :: new_arctan_neuron
end interface arctan_neuron_t
contains
*/
\ No newline at end of file
......@@ -42,4 +42,4 @@ void Neuron::activation_function_set_parameter(int param_idx, double value) {
double Neuron::activation_function_get_parameter(int param_idx) {
return this->activation_function_parameters[param_idx];
}
\ No newline at end of file
}
......@@ -2,7 +2,7 @@
#define NEURON_H_
/**
* Module containing classes representing neurons
* A file containing the mother classe representing neurons
* in neural networks.
*
* @author Martin Beseda
......@@ -17,7 +17,7 @@
*/
class Neuron{
private:
protected:
/**
* Inner potential of the neuron (input of the activation function)
*/
......
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