layer_type Derived Type

type, public :: layer_type


Inherited by

type~~layer_type~~InheritedByGraph type~layer_type layer_type type~network_type network_type type~network_type->type~layer_type layers

Contents

Source Code


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

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)


Type-Bound Procedures

procedure, public, pass(self) :: set_activation

  • 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

Source Code

  type :: layer_type
    real(rk), allocatable :: a(:) !! activations
    real(rk), allocatable :: b(:) !! biases
    real(rk), allocatable :: w(:,:) !! weights
    real(rk), allocatable :: z(:) !! arg. to activation function
    procedure(activation_function), pointer, nopass :: activation => null()
    procedure(activation_function), pointer, nopass :: activation_prime => null()
    character(len=:), allocatable :: activation_str !! activation character string
  contains
    procedure, public, pass(self) :: set_activation
  end type layer_type