mod_layer Module

Defines the layer type and its methods.


Uses

  • module~~mod_layer~~UsesGraph module~mod_layer mod_layer module~mod_random mod_random module~mod_layer->module~mod_random module~mod_activation mod_activation module~mod_layer->module~mod_activation module~mod_kinds mod_kinds module~mod_layer->module~mod_kinds module~mod_random->module~mod_kinds module~mod_activation->module~mod_kinds iso_fortran_env iso_fortran_env module~mod_kinds->iso_fortran_env

Used by

  • module~~mod_layer~~UsedByGraph module~mod_layer mod_layer module~mod_network mod_network module~mod_network->module~mod_layer

Contents


Interfaces

public interface array1d

  • private pure function array1d_constructor(length) result(a)

    Overloads the default type constructor.

    Arguments

    Type IntentOptional AttributesName
    integer(kind=ik), intent(in) :: length

    Return Value type(array1d)

public interface array2d

  • private pure function array2d_constructor(dims) result(a)

    Overloads the default type constructor.

    Arguments

    Type IntentOptional AttributesName
    integer(kind=ik), intent(in) :: dims(2)

    Return Value type(array2d)

public interface layer_type

  • private function constructor(this_size, next_size) result(layer)

    Layer class constructor. this_size is the number of neurons in the layer. next_size is the number of neurons in the next layer, used to allocate the weights.

    Arguments

    Type IntentOptional AttributesName
    integer(kind=ik), intent(in) :: this_size
    integer(kind=ik), intent(in) :: next_size

    Return Value type(layer_type)


Derived Types

type, public :: array1d

Components

TypeVisibility AttributesNameInitial
real(kind=rk), public, allocatable:: array(:)

Constructor

private pure function array1d_constructor(length)

Overloads the default type constructor.

type, public :: array2d

Components

TypeVisibility AttributesNameInitial
real(kind=rk), public, allocatable:: array(:,:)

Constructor

private pure function array2d_constructor(dims)

Overloads the default type constructor.

type, public :: layer_type

Components

TypeVisibility AttributesNameInitial
real(kind=rk), public, allocatable:: a(:)

activations

procedure(activation_function), public, pointer, nopass:: activation=> null()
procedure(activation_function), public, pointer, nopass:: activation_prime=> null()
character(len=:), public, allocatable:: activation_str

activation character string

real(kind=rk), public, allocatable:: b(:)

biases

real(kind=rk), public, allocatable:: w(:,:)

weights

real(kind=rk), public, allocatable:: z(:)

arg. to activation function

Constructor

private function constructor(this_size, next_size)

Layer class constructor. this_size is the number of neurons in the layer. next_size is the number of neurons in the next layer, used to allocate the weights.

Type-Bound Procedures

procedure, public, pass(self) :: set_activation

Functions

private pure function array1d_constructor(length) result(a)

Overloads the default type constructor.

Arguments

Type IntentOptional AttributesName
integer(kind=ik), intent(in) :: length

Return Value type(array1d)

private pure function array2d_constructor(dims) result(a)

Overloads the default type constructor.

Arguments

Type IntentOptional AttributesName
integer(kind=ik), intent(in) :: dims(2)

Return Value type(array2d)

private function constructor(this_size, next_size) result(layer)

Layer class constructor. this_size is the number of neurons in the layer. next_size is the number of neurons in the next layer, used to allocate the weights.

Arguments

Type IntentOptional AttributesName
integer(kind=ik), intent(in) :: this_size
integer(kind=ik), intent(in) :: next_size

Return Value type(layer_type)


Subroutines

public subroutine db_co_sum(db)

Performs a collective sum of bias tendencies.

Arguments

Type IntentOptional AttributesName
type(array1d), intent(inout), allocatable:: db(:)

public pure subroutine db_init(db, dims)

Initialises biases structure.

Arguments

Type IntentOptional AttributesName
type(array1d), intent(inout), allocatable:: db(:)
integer(kind=ik), intent(in) :: dims(:)

public subroutine dw_co_sum(dw)

Performs a collective sum of weights tendencies.

Arguments

Type IntentOptional AttributesName
type(array2d), intent(inout), allocatable:: dw(:)

public pure subroutine dw_init(dw, dims)

Initialises weights structure.

Arguments

Type IntentOptional AttributesName
type(array2d), intent(inout), allocatable:: dw(:)
integer(kind=ik), intent(in) :: dims(:)

private pure elemental subroutine set_activation(self, activation)

Sets the activation function. Input string must match one of provided activation functions, otherwise it defaults to sigmoid. If activation not present, defaults to sigmoid.

Arguments

Type IntentOptional AttributesName
class(layer_type), intent(inout) :: self
character(len=*), intent(in) :: activation