Commit 30617b57 authored by Martin Beseda's avatar Martin Beseda
Browse files

ENH: Added parametric constructor into the module neuron_m, to the class linear_neuron_t.

parent e75eb729
......@@ -133,17 +133,28 @@ module neuron_m
! class linear_neuron_t !
!-----------------------!
!> Linear neuron class - returns its potential as the output of the activation function
!> 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
!! Coefficients for the linear activation function in format 'f(x)=a*x + b'
real, private :: a_coef !> The coefficient 'a' in the activation function f(x)=a*x + b
real, private :: b_coef !> The coefficient 'b' in the activation function f(x)=a*x + b
contains
!> Activation function - just returns the neuron's potential value
!> Activation function - f(x)=a*x + b
procedure, private :: activate => identity_potential_activate_impl
end type linear_neuron_t
interface linear_neuron_t
!> Constructor of linear_neuron_t class
!> Non-parametric constructor of linear_neuron_t class - a coef. is 1, b coef. is 0
module procedure :: new_linear_neuron
!> Constructor of linear_neuron_t class
!! @param a_coef a coef. of the linear activation function
!! @param b_coef b coef. of the linear activation fucntion
module procedure :: new_linear_neuron_2
end interface linear_neuron_t
!--------------------------!-------------------------------------------------------------------
......@@ -221,19 +232,6 @@ module neuron_m
#endif
end function get_id_impl
! function get_parent_interconnection_impl(this) result(parent_interconnection)
! class(neuron_t), intent(in) :: this
! class(interconnection_t) :: parent_interconnection
!#ifdef TIME_PROFILING
! real :: start_time
! call time_profiling_start(start_time)
!#endif
! parent_interconnection = this%parent_interconnection
!#ifdef TIME_PROFILING
! call time_profiling_stop(start_time, 'get_parent_interconnection_impl')
!#endif
! end function get_parent_interconnection_impl
!----------------!-----------------------------------------------------------------------------
! Common methods !
!----------------!
......@@ -429,7 +427,7 @@ module neuron_m
! Constructors !
!--------------!
!> Constructor of linear_neuron_t class
!> Non-parametric constructor of linear_neuron_t class - a coef. is 1, b coef. is 0
function new_linear_neuron() result(new_obj)
type(linear_neuron_t), pointer :: new_obj
#ifdef TIME_PROFILING
......@@ -440,11 +438,38 @@ module neuron_m
allocate(new_obj)
call new_obj%init_components()
new_obj%a_coef = 1
new_obj%b_coef = 0
#ifdef TIME_PROFILING
call time_profiling_stop(start_time, 'new_linear_neuron')
#endif
end function new_linear_neuron
!> Constructor of linear_neuron_t class
!! @param a_coef a coef. of the linear activation function
!! @param b_coef b coef. of the linear activation fucntion
function new_linear_neuron_2(a_coef, b_coef) result(new_obj)
real, intent(in) :: a_coef
real, intent(in) :: b_coef
type(linear_neuron_t), pointer :: new_obj
#ifdef TIME_PROFILING
real :: start_time
call time_profiling_start(start_time)
#endif
allocate(new_obj)
call new_obj%init_components()
new_obj%a_coef = a_coef
new_obj%b_coef = b_coef
#ifdef TIME_PROFILING
call time_profiling_stop(start_time, 'new_linear_neuron_2')
#endif
end function new_linear_neuron_2
!----------------!---------------------------------------------------------------------------
! Common methods !
!----------------!
......
Supports Markdown
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