athena__base_layer Module

Module containing the abstract base layer type

This module contains the abstract base layer type, from which all other layers are derived. The module also contains the abstract derived types for the following layer types: - padding - pooling - dropout - learnable - convolutional - batch normalisation

The following procedures are based on code from the neural-fortran library https://github.com/modern-fortran/neural-fortran/blob/main/src/nf/nf_layer.f90


Uses


Interfaces

interface

interface

  • private module subroutine build_from_onnx_base(this, node, initialisers, value_info, verbose)

    Build layer from ONNX node

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(inout) :: this

    Instance of the layer

    type(onnx_node_type), intent(in) :: node

    ONNX node

    type(onnx_initialiser_type), intent(in), dimension(:) :: initialisers

    ONNX initialisers

    type(onnx_tensor_type), intent(in), dimension(:) :: value_info

    ONNX value info

    integer, intent(in) :: verbose

    Verbosity level

interface

  • private module function calc_input_shape(this, input_shapes) result(input_shape)

    Calculate input shape based on shapes of input layers

    Arguments

    Type IntentOptional Attributes Name
    class(merge_layer_type), intent(in) :: this

    Instance of the layer

    integer, intent(in), dimension(:,:) :: input_shapes

    Input shapes

    Return Value integer, allocatable, dimension(:)

    Calculated input shape

interface

  • private module subroutine combine_merge(this, input_list)

    Combine two layers (forward)

    Arguments

    Type IntentOptional Attributes Name
    class(merge_layer_type), intent(inout) :: this

    Instance of the layer

    type(array_ptr_type), intent(in), dimension(:) :: input_list

    Input values

interface

  • private module subroutine emit_onnx_graph_inputs_base(this, prefix, graph_inputs, num_inputs)

    Emit graph input tensor declarations for this layer Default implementation does nothing; override for GNN layers

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(in) :: this

    Instance of the layer

    character(len=*), intent(in) :: prefix

    Input name prefix (e.g. "input_1")

    type(onnx_tensor_type), intent(inout), dimension(:) :: graph_inputs

    Accumulator for graph inputs

    integer, intent(inout) :: num_inputs

    Current number of inputs

interface

  • private module subroutine emit_onnx_nodes_base(this, prefix, nodes, num_nodes, max_nodes, inits, num_inits, max_inits, input_name, is_last_layer, format)

    Emit ONNX JSON nodes for this layer Default implementation does nothing; override for GNN/NOP layers

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(in) :: this

    Instance of the layer

    character(len=*), intent(in) :: prefix

    Node name prefix (e.g. "node_2")

    type(onnx_node_type), intent(inout), dimension(:) :: nodes

    Accumulator for ONNX nodes

    integer, intent(inout) :: num_nodes

    Current number of nodes

    integer, intent(in) :: max_nodes

    Maximum capacity

    type(onnx_initialiser_type), intent(inout), dimension(:) :: inits

    Accumulator for ONNX initialisers

    integer, intent(inout) :: num_inits

    Current number of initialisers

    integer, intent(in) :: max_inits

    Maximum capacity

    character(len=*), intent(in), optional :: input_name

    Upstream tensor name used by sequential expanded ONNX format

    logical, intent(in), optional :: is_last_layer

    Whether this is the last non-input layer in the network

    integer, intent(in), optional :: format

    Export format selector 1 = ONNX athena abstract format (default) 2 = ONNX expanded format

interface

  • private module subroutine extract_output_base(this, output)

    Extract the output of the layer as a standard real array

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(in) :: this

    Instance of the layer

    real(kind=real32), intent(out), dimension(..), allocatable :: output

    Output values

interface

  • private module subroutine forward_base(this, input)

    Forward pass of layer

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(inout) :: this

    Instance of the layer

    class(array_type), intent(in), dimension(:,:) :: input

    Input data

interface

  • private module function forward_eval_base(this, input) result(output)

    Forward pass of layer and return output for evaluation

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(inout), target :: this

    Instance of the layer

    class(array_type), intent(in), dimension(:,:) :: input

    Input data

    Return Value type(array_type), pointer, (:,:)

    Output data

interface

  • private module function get_attributes_base(this) result(attributes)

    Get the attributes of the layer (for ONNX export)

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(in) :: this

    Instance of the layer

    Return Value type(onnx_attribute_type), allocatable, dimension(:)

    Attributes of the layer

interface

  • private module function get_attributes_batch(this) result(attributes)

    Arguments

    Type IntentOptional Attributes Name
    class(batch_layer_type), intent(in) :: this

    Instance of the layer

    Return Value type(onnx_attribute_type), allocatable, dimension(:)

    Attributes of the layer

interface

interface

  • private module function get_attributes_pool(this) result(attributes)

    Get the attributes of the layer (for ONNX export)

    Arguments

    Type IntentOptional Attributes Name
    class(pool_layer_type), intent(in) :: this

    Instance of the layer

    Return Value type(onnx_attribute_type), allocatable, dimension(:)

    Attributes of the layer

interface

  • private pure module function get_gradients(this, clip_method) result(gradients)

    Get parameter gradients of layer

    Arguments

    Type IntentOptional Attributes Name
    class(learnable_layer_type), intent(in) :: this

    Instance of the layer

    type(clip_type), intent(in), optional :: clip_method

    Clip method

    Return Value real(kind=real32), dimension(this%num_params)

    Parameter gradients

interface

  • private pure module function get_num_params(this) result(num_params)

    Get number of parameters in layer

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(in) :: this

    Instance of the layer

    Return Value integer

    Number of parameters

interface

  • private pure module function get_num_params_base(this) result(num_params)

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(in) :: this

    Return Value integer

interface

  • private pure module function get_num_params_batch(this) result(num_params)

    Arguments

    Type IntentOptional Attributes Name
    class(batch_layer_type), intent(in) :: this

    Return Value integer

interface

  • private pure module function get_num_params_conv(this) result(num_params)

    Arguments

    Type IntentOptional Attributes Name
    class(conv_layer_type), intent(in) :: this

    Return Value integer

interface

  • private pure module function get_params(this) result(params)

    Get learnable parameters of layer

    Arguments

    Type IntentOptional Attributes Name
    class(learnable_layer_type), intent(in) :: this

    Instance of the layer

    Return Value real(kind=real32), dimension(this%num_params)

    Learnable parameters

interface

  • private module subroutine init_batch(this, input_shape, verbose)

    Arguments

    Type IntentOptional Attributes Name
    class(batch_layer_type), intent(inout) :: this
    integer, intent(in), dimension(:) :: input_shape
    integer, intent(in), optional :: verbose

interface

  • private module subroutine init_conv(this, input_shape, verbose)

    Arguments

    Type IntentOptional Attributes Name
    class(conv_layer_type), intent(inout) :: this
    integer, intent(in), dimension(:) :: input_shape
    integer, intent(in), optional :: verbose

interface

  • private module subroutine init_pad(this, input_shape, verbose)

    Arguments

    Type IntentOptional Attributes Name
    class(pad_layer_type), intent(inout) :: this
    integer, intent(in), dimension(:) :: input_shape
    integer, intent(in), optional :: verbose

interface

  • private module subroutine init_pool(this, input_shape, verbose)

    Arguments

    Type IntentOptional Attributes Name
    class(pool_layer_type), intent(inout) :: this
    integer, intent(in), dimension(:) :: input_shape
    integer, intent(in), optional :: verbose

interface

  • private module subroutine initialise(this, input_shape, verbose)

    Initialise the layer

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(inout) :: this

    Instance of the layer

    integer, intent(in), dimension(:) :: input_shape

    Input shape

    integer, intent(in), optional :: verbose

    Verbosity level

interface

  • private module subroutine nullify_graph_base(this)

    Nullify the forward pass data of the layer to free memory

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(inout) :: this

    Instance of the layer

interface

  • private module subroutine print_base(this, file, unit, print_header_footer)

    Print the layer to a file with additional information

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(in) :: this

    Instance of the layer

    character(len=*), intent(in), optional :: file

    File name

    integer, intent(in), optional :: unit

    Unit number

    logical, intent(in), optional :: print_header_footer

    Boolean whether to print header and footer

interface

  • private module subroutine print_to_unit_base(this, unit)

    Print the layer to a file

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(in) :: this

    Instance of the layer

    integer, intent(in) :: unit

    File unit

interface

  • private module subroutine print_to_unit_batch(this, unit)

    Print layer to unit

    Arguments

    Type IntentOptional Attributes Name
    class(batch_layer_type), intent(in) :: this

    Instance of the layer

    integer, intent(in) :: unit

    File unit

interface

  • private module subroutine print_to_unit_conv(this, unit)

    Print layer to unit

    Arguments

    Type IntentOptional Attributes Name
    class(conv_layer_type), intent(in) :: this

    Instance of the layer

    integer, intent(in) :: unit

    File unit

interface

  • private module subroutine print_to_unit_pad(this, unit)

    Print layer to unit

    Arguments

    Type IntentOptional Attributes Name
    class(pad_layer_type), intent(in) :: this

    Instance of the layer

    integer, intent(in) :: unit

    File unit

interface

  • private module subroutine print_to_unit_pool(this, unit)

    Print layer to unit

    Arguments

    Type IntentOptional Attributes Name
    class(pool_layer_type), intent(in) :: this

    Instance of the layer

    integer, intent(in) :: unit

    File unit

interface

  • private module subroutine read_layer(this, unit, verbose)

    Read layer from file

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(inout) :: this

    Instance of the layer

    integer, intent(in) :: unit

    File unit

    integer, intent(in), optional :: verbose

    Verbosity level

interface

  • private module subroutine reduce_learnable(this, input)

    Merge another learnable layer into this one

    Arguments

    Type IntentOptional Attributes Name
    class(learnable_layer_type), intent(inout) :: this

    Instance of the layer

    class(learnable_layer_type), intent(in) :: input

    Other layer to merge

interface

  • private module subroutine set_gradients(this, gradients)

    Set learnable parameters of layer

    Arguments

    Type IntentOptional Attributes Name
    class(learnable_layer_type), intent(inout) :: this

    Instance of the layer

    real(kind=real32), intent(in), dimension(..) :: gradients

    Learnable parameters

interface

  • private module subroutine set_graph_base(this, graph)

    Set the graph structure of the input data

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(inout) :: this

    Instance of the layer

    type(graph_type), intent(in), dimension(:) :: graph

    Graph structure of input data

interface

  • private module subroutine set_params(this, params)

    Set learnable parameters of layer

    Arguments

    Type IntentOptional Attributes Name
    class(learnable_layer_type), intent(inout) :: this

    Instance of the layer

    real(kind=real32), intent(in), dimension(this%num_params) :: params

    Learnable parameters

interface

  • private module subroutine set_rank_base(this, input_rank, output_rank)

    Set the input and output ranks of the layer

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(inout) :: this

    Instance of the layer

    integer, intent(in) :: input_rank

    Input rank

    integer, intent(in) :: output_rank

    Output rank

interface

  • private module subroutine set_shape_base(this, input_shape)

    Set the input shape of the layer

    Arguments

    Type IntentOptional Attributes Name
    class(base_layer_type), intent(inout) :: this

    Instance of the layer

    integer, intent(in), dimension(:) :: input_shape

    Input shape


Abstract Interfaces

abstract interface

  • private subroutine generate_mask(this)

    Generate dropout mask

    Arguments

    Type IntentOptional Attributes Name
    class(drop_layer_type), intent(inout) :: this

    Instance of the layer


Derived Types

type, public, abstract ::  base_layer_type

Type for base layer, from which all other layers are derived

Components

Type Visibility Attributes Name Initial
type(graph_type), public, allocatable, dimension(:) :: graph

Graph structure of input data

integer, public :: id

Unique identifier

logical, public :: inference = .false.

Inference mode

integer, public :: input_rank = 0

Rank of input data

integer, public, allocatable, dimension(:) :: input_shape

Input shape

character(len=:), public, allocatable :: name

Layer name

class(array_type), public, allocatable, dimension(:,:) :: output

Output

integer, public :: output_rank = 0

Rank of output data

integer, public, allocatable, dimension(:) :: output_shape

Output shape

character(len=20), public :: subtype = repeat(" ", 20)
character(len=4), public :: type = 'base'

Layer type

logical, public :: use_graph_input = .false.

Use graph input

logical, public :: use_graph_output = .false.

Use graph output

Type-Bound Procedures

procedure, public, pass(this) :: build_from_onnx => build_from_onnx_base

Build layer from ONNX node and initialiser

procedure, public, pass(this) :: emit_onnx_graph_inputs => emit_onnx_graph_inputs_base

Emit graph input tensor declarations for this layer

procedure, public, pass(this) :: emit_onnx_nodes => emit_onnx_nodes_base

Emit ONNX JSON nodes for this layer (format-aware and polymorphic)

procedure, public, pass(this) :: extract_output => extract_output_base

Extract the output of the layer as a standard real array

procedure, public, pass(this) :: forward => forward_base

Forward pass of layer

procedure, public, pass(this) :: forward_eval => forward_eval_base

Forward pass of layer and return output for evaluation

procedure, public, pass(this) :: get_attributes => get_attributes_base

Get the attributes of the layer (for ONNX export)

procedure, public, pass(this) :: get_num_params => get_num_params_base

Get the number of parameters in the layer

procedure(initialise), public, deferred, pass(this) :: init

Initialise the layer

procedure, public, pass(this) :: nullify_graph => nullify_graph_base

Nullify the forward pass data of the layer to free memory

Read more…
procedure, public, pass(this) :: print => print_base

Print the layer to a file with additional information

procedure, public, pass(this) :: print_to_unit => print_to_unit_base

Print the layer to a unit

procedure(read_layer), public, deferred, pass(this) :: read

Read layer from file

procedure, public, pass(this) :: set_graph => set_graph_base

Set the graph structure of the input data !! this is adjacency and edge weighting

procedure, public, pass(this) :: set_rank => set_rank_base

Set the input and output ranks of the layer

procedure, public, pass(this) :: set_shape => set_shape_base

Set the input shape of the layer

type, public, abstract, extends(learnable_layer_type) ::  batch_layer_type

Type for batch normalisation layers

Components

Type Visibility Attributes Name Initial
class(base_actv_type), public, allocatable :: activation

Activation function

real(kind=real32), public :: beta_init_mean = 0._real32

Initialisation parameters for beta

real(kind=real32), public :: beta_init_std = 0.01_real32

Initialisation parameters for beta

class(base_init_type), public, allocatable :: bias_init

Initialisers for kernel and bias

character(len=14), public :: bias_initialiser = ''

Initialisers for kernel and bias

integer, public, allocatable, dimension(:) :: bias_shape

Shape of biases

real(kind=real32), public :: epsilon = 0.001_real32

Epsilon factor

real(kind=real32), public :: gamma_init_mean = 1._real32

Initialisation parameters for gamma

real(kind=real32), public :: gamma_init_std = 0.01_real32

Initialisation parameters for gamma

type(graph_type), public, allocatable, dimension(:) :: graph

Graph structure of input data

integer, public :: id

Unique identifier

logical, public :: inference = .false.

Inference mode

integer, public :: input_rank = 0

Rank of input data

integer, public, allocatable, dimension(:) :: input_shape

Input shape

class(base_init_type), public, allocatable :: kernel_init

Initialisers for kernel and bias

character(len=14), public :: kernel_initialiser = ''

Initialisers for kernel and bias

real(kind=real32), public, allocatable, dimension(:) :: mean

Mean and variance (not learnable)

real(kind=real32), public :: momentum = 0.99_real32

Momentum factor NOTE: if momentum = 0, mean and variance batch-dependent values NOTE: if momentum > 0, mean and variance are running averages

class(base_init_type), public, allocatable :: moving_mean_init

Initialisers for moving mean and variance

class(base_init_type), public, allocatable :: moving_variance_init

Initialisers for moving mean and variance

character(len=:), public, allocatable :: name

Layer name

integer, public :: num_channels

Number of channels

integer, public :: num_params = 0

Number of learnable parameters

class(array_type), public, allocatable, dimension(:,:) :: output

Output

integer, public :: output_rank = 0

Rank of output data

integer, public, allocatable, dimension(:) :: output_shape

Output shape

type(array_type), public, allocatable, dimension(:) :: params

Learnable parameters

character(len=20), public :: subtype = repeat(" ", 20)
character(len=4), public :: type = 'base'

Layer type

logical, public :: use_bias = .false.

Layer has bias

logical, public :: use_graph_input = .false.

Use graph input

logical, public :: use_graph_output = .false.

Use graph output

real(kind=real32), public, allocatable, dimension(:) :: variance

Mean and variance (not learnable)

integer, public, allocatable, dimension(:,:) :: weight_shape

Shape of weights

Type-Bound Procedures

procedure, public :: add_t_t => add_learnable

Add two layers

procedure, public, pass(this) :: build_from_onnx => build_from_onnx_base

Build layer from ONNX node and initialiser

procedure, public, pass(this) :: emit_onnx_graph_inputs => emit_onnx_graph_inputs_base

Emit graph input tensor declarations for this layer

procedure, public, pass(this) :: emit_onnx_nodes => emit_onnx_nodes_base

Emit ONNX JSON nodes for this layer (format-aware and polymorphic)

procedure, public, pass(this) :: extract_output => extract_output_base

Extract the output of the layer as a standard real array

procedure, public, pass(this) :: forward => forward_base

Forward pass of layer

procedure, public, pass(this) :: forward_eval => forward_eval_base

Forward pass of layer and return output for evaluation

procedure, public, pass(this) :: get_attributes => get_attributes_batch

Get the attributes of the layer (for ONNX export)

procedure, public, pass(this) :: get_gradients

Get parameter gradients of layer

procedure, public, pass(this) :: get_num_params => get_num_params_batch

Get the number of parameters in the layer

procedure, public, pass(this) :: get_params

Get learnable parameters of layer

procedure, public, pass(this) :: init => init_batch

Initialise the layer

procedure, public, pass(this) :: nullify_graph => nullify_graph_base

Nullify the forward pass data of the layer to free memory

Read more…
generic, public :: operator(+) => add_t_t

Operator overloading for addition

procedure, public, pass(this) :: print => print_base

Print the layer to a file with additional information

procedure, public, pass(this) :: print_to_unit => print_to_unit_batch

Print layer to unit

procedure(read_layer), public, deferred, pass(this) :: read

Read layer from file

procedure, public, pass(this) :: reduce => reduce_learnable

Merge another learnable layer into this one

procedure, public, pass(this) :: set_gradients

Set learnable parameters of layer

procedure, public, pass(this) :: set_graph => set_graph_base

Set the graph structure of the input data !! this is adjacency and edge weighting

procedure, public, pass(this) :: set_params

Set learnable parameters of layer

procedure, public, pass(this) :: set_rank => set_rank_base

Set the input and output ranks of the layer

procedure, public, pass(this) :: set_shape => set_shape_base

Set the input shape of the layer

type, public, abstract, extends(learnable_layer_type) ::  conv_layer_type

Components

Type Visibility Attributes Name Initial
class(base_actv_type), public, allocatable :: activation

Activation function

real(kind=real32), public, pointer :: bias(:) => null()

Bias pointer

class(base_init_type), public, allocatable :: bias_init

Initialisers for kernel and bias

character(len=14), public :: bias_initialiser = ''

Initialisers for kernel and bias

integer, public, allocatable, dimension(:) :: bias_shape

Shape of biases

class(array_type), public, allocatable :: di_padded

Padded input gradients

integer, public, allocatable, dimension(:) :: dil

Kernel, stride, and dilation sizes

type(graph_type), public, allocatable, dimension(:) :: graph

Graph structure of input data

integer, public :: id

Unique identifier

logical, public :: inference = .false.

Inference mode

integer, public :: input_rank = 0

Rank of input data

integer, public, allocatable, dimension(:) :: input_shape

Input shape

class(base_init_type), public, allocatable :: kernel_init

Initialisers for kernel and bias

character(len=14), public :: kernel_initialiser = ''

Initialisers for kernel and bias

integer, public, allocatable, dimension(:) :: knl

Kernel, stride, and dilation sizes

character(len=:), public, allocatable :: name

Layer name

integer, public :: num_channels

Number of channels

integer, public :: num_filters

Number of filters

integer, public :: num_params = 0

Number of learnable parameters

class(array_type), public, allocatable, dimension(:,:) :: output

Output

integer, public :: output_rank = 0

Rank of output data

integer, public, allocatable, dimension(:) :: output_shape

Output shape

class(pad_layer_type), public, allocatable :: pad_layer

Optional preprocess padding layer

type(array_type), public, allocatable, dimension(:) :: params

Learnable parameters

integer, public, allocatable, dimension(:) :: stp

Kernel, stride, and dilation sizes

character(len=20), public :: subtype = repeat(" ", 20)
character(len=4), public :: type = 'base'

Layer type

logical, public :: use_bias = .false.

Layer has bias

logical, public :: use_graph_input = .false.

Use graph input

logical, public :: use_graph_output = .false.

Use graph output

integer, public, allocatable, dimension(:,:) :: weight_shape

Shape of weights

type(array_type), public, dimension(2) :: z

Temporary arrays for forward propagation

Type-Bound Procedures

procedure, public :: add_t_t => add_learnable

Add two layers

procedure, public, pass(this) :: build_from_onnx => build_from_onnx_base

Build layer from ONNX node and initialiser

procedure, public, pass(this) :: emit_onnx_graph_inputs => emit_onnx_graph_inputs_base

Emit graph input tensor declarations for this layer

procedure, public, pass(this) :: emit_onnx_nodes => emit_onnx_nodes_base

Emit ONNX JSON nodes for this layer (format-aware and polymorphic)

procedure, public, pass(this) :: extract_output => extract_output_base

Extract the output of the layer as a standard real array

procedure, public, pass(this) :: forward => forward_base

Forward pass of layer

procedure, public, pass(this) :: forward_eval => forward_eval_base

Forward pass of layer and return output for evaluation

procedure, public, pass(this) :: get_attributes => get_attributes_conv

Get the attributes of the layer (for ONNX export)

procedure, public, pass(this) :: get_gradients

Get parameter gradients of layer

procedure, public, pass(this) :: get_num_params => get_num_params_conv

Get the number of parameters in the layer

procedure, public, pass(this) :: get_params

Get learnable parameters of layer

procedure, public, pass(this) :: init => init_conv

Initialise the layer

procedure, public, pass(this) :: nullify_graph => nullify_graph_base

Nullify the forward pass data of the layer to free memory

Read more…
generic, public :: operator(+) => add_t_t

Operator overloading for addition

procedure, public, pass(this) :: print => print_base

Print the layer to a file with additional information

procedure, public, pass(this) :: print_to_unit => print_to_unit_conv

Print layer to unit

procedure(read_layer), public, deferred, pass(this) :: read

Read layer from file

procedure, public, pass(this) :: reduce => reduce_learnable

Merge another learnable layer into this one

procedure, public, pass(this) :: set_gradients

Set learnable parameters of layer

procedure, public, pass(this) :: set_graph => set_graph_base

Set the graph structure of the input data !! this is adjacency and edge weighting

procedure, public, pass(this) :: set_params

Set learnable parameters of layer

procedure, public, pass(this) :: set_rank => set_rank_base

Set the input and output ranks of the layer

procedure, public, pass(this) :: set_shape => set_shape_base

Set the input shape of the layer

type, public, abstract, extends(base_layer_type) ::  drop_layer_type

Type for dropout layers

Components

Type Visibility Attributes Name Initial
type(graph_type), public, allocatable, dimension(:) :: graph

Graph structure of input data

integer, public :: id

Unique identifier

logical, public :: inference = .false.

Inference mode

integer, public :: input_rank = 0

Rank of input data

integer, public, allocatable, dimension(:) :: input_shape

Input shape

character(len=:), public, allocatable :: name

Layer name

class(array_type), public, allocatable, dimension(:,:) :: output

Output

integer, public :: output_rank = 0

Rank of output data

integer, public, allocatable, dimension(:) :: output_shape

Output shape

real(kind=real32), public :: rate = 0.1_real32

Dropout rate, rate = 1 - keep_prob -- typical = 0.05-0.25

character(len=20), public :: subtype = repeat(" ", 20)
character(len=4), public :: type = 'base'

Layer type

logical, public :: use_graph_input = .false.

Use graph input

logical, public :: use_graph_output = .false.

Use graph output

Type-Bound Procedures

procedure, public, pass(this) :: build_from_onnx => build_from_onnx_base

Build layer from ONNX node and initialiser

procedure, public, pass(this) :: emit_onnx_graph_inputs => emit_onnx_graph_inputs_base

Emit graph input tensor declarations for this layer

procedure, public, pass(this) :: emit_onnx_nodes => emit_onnx_nodes_base

Emit ONNX JSON nodes for this layer (format-aware and polymorphic)

procedure, public, pass(this) :: extract_output => extract_output_base

Extract the output of the layer as a standard real array

procedure, public, pass(this) :: forward => forward_base

Forward pass of layer

procedure, public, pass(this) :: forward_eval => forward_eval_base

Forward pass of layer and return output for evaluation

procedure(generate_mask), public, deferred, pass(this) :: generate_mask

Generate dropout mask

procedure, public, pass(this) :: get_attributes => get_attributes_base

Get the attributes of the layer (for ONNX export)

procedure, public, pass(this) :: get_num_params => get_num_params_base

Get the number of parameters in the layer

procedure(initialise), public, deferred, pass(this) :: init

Initialise the layer

procedure, public, pass(this) :: nullify_graph => nullify_graph_base

Nullify the forward pass data of the layer to free memory

Read more…
procedure, public, pass(this) :: print => print_base

Print the layer to a file with additional information

procedure, public, pass(this) :: print_to_unit => print_to_unit_base

Print the layer to a unit

procedure(read_layer), public, deferred, pass(this) :: read

Read layer from file

procedure, public, pass(this) :: set_graph => set_graph_base

Set the graph structure of the input data !! this is adjacency and edge weighting

procedure, public, pass(this) :: set_rank => set_rank_base

Set the input and output ranks of the layer

procedure, public, pass(this) :: set_shape => set_shape_base

Set the input shape of the layer

type, public, abstract, extends(base_layer_type) ::  learnable_layer_type

Type for layers with learnable parameters

Components

Type Visibility Attributes Name Initial
class(base_actv_type), public, allocatable :: activation

Activation function

class(base_init_type), public, allocatable :: bias_init

Initialisers for kernel and bias

character(len=14), public :: bias_initialiser = ''

Initialisers for kernel and bias

integer, public, allocatable, dimension(:) :: bias_shape

Shape of biases

type(graph_type), public, allocatable, dimension(:) :: graph

Graph structure of input data

integer, public :: id

Unique identifier

logical, public :: inference = .false.

Inference mode

integer, public :: input_rank = 0

Rank of input data

integer, public, allocatable, dimension(:) :: input_shape

Input shape

class(base_init_type), public, allocatable :: kernel_init

Initialisers for kernel and bias

character(len=14), public :: kernel_initialiser = ''

Initialisers for kernel and bias

character(len=:), public, allocatable :: name

Layer name

integer, public :: num_params = 0

Number of learnable parameters

class(array_type), public, allocatable, dimension(:,:) :: output

Output

integer, public :: output_rank = 0

Rank of output data

integer, public, allocatable, dimension(:) :: output_shape

Output shape

type(array_type), public, allocatable, dimension(:) :: params

Learnable parameters

character(len=20), public :: subtype = repeat(" ", 20)
character(len=4), public :: type = 'base'

Layer type

logical, public :: use_bias = .false.

Layer has bias

logical, public :: use_graph_input = .false.

Use graph input

logical, public :: use_graph_output = .false.

Use graph output

integer, public, allocatable, dimension(:,:) :: weight_shape

Shape of weights

Type-Bound Procedures

procedure, public :: add_t_t => add_learnable

Add two layers

procedure, public, pass(this) :: build_from_onnx => build_from_onnx_base

Build layer from ONNX node and initialiser

procedure, public, pass(this) :: emit_onnx_graph_inputs => emit_onnx_graph_inputs_base

Emit graph input tensor declarations for this layer

procedure, public, pass(this) :: emit_onnx_nodes => emit_onnx_nodes_base

Emit ONNX JSON nodes for this layer (format-aware and polymorphic)

procedure, public, pass(this) :: extract_output => extract_output_base

Extract the output of the layer as a standard real array

procedure, public, pass(this) :: forward => forward_base

Forward pass of layer

procedure, public, pass(this) :: forward_eval => forward_eval_base

Forward pass of layer and return output for evaluation

procedure, public, pass(this) :: get_attributes => get_attributes_base

Get the attributes of the layer (for ONNX export)

procedure, public, pass(this) :: get_gradients

Get parameter gradients of layer

procedure, public, pass(this) :: get_num_params => get_num_params_base

Get the number of parameters in the layer

procedure, public, pass(this) :: get_params

Get learnable parameters of layer

procedure(initialise), public, deferred, pass(this) :: init

Initialise the layer

procedure, public, pass(this) :: nullify_graph => nullify_graph_base

Nullify the forward pass data of the layer to free memory

Read more…
generic, public :: operator(+) => add_t_t

Operator overloading for addition

procedure, public, pass(this) :: print => print_base

Print the layer to a file with additional information

procedure, public, pass(this) :: print_to_unit => print_to_unit_base

Print the layer to a unit

procedure(read_layer), public, deferred, pass(this) :: read

Read layer from file

procedure, public, pass(this) :: reduce => reduce_learnable

Merge another learnable layer into this one

procedure, public, pass(this) :: set_gradients

Set learnable parameters of layer

procedure, public, pass(this) :: set_graph => set_graph_base

Set the graph structure of the input data !! this is adjacency and edge weighting

procedure, public, pass(this) :: set_params

Set learnable parameters of layer

procedure, public, pass(this) :: set_rank => set_rank_base

Set the input and output ranks of the layer

procedure, public, pass(this) :: set_shape => set_shape_base

Set the input shape of the layer

type, public, abstract, extends(base_layer_type) ::  merge_layer_type

Type for merge layers (i.e. add, multiply, concatenate)

Components

Type Visibility Attributes Name Initial
type(graph_type), public, allocatable, dimension(:) :: graph

Graph structure of input data

integer, public :: id

Unique identifier

logical, public :: inference = .false.

Inference mode

integer, public, allocatable, dimension(:) :: input_layer_ids

IDs of input layers

integer, public :: input_rank = 0

Rank of input data

integer, public, allocatable, dimension(:) :: input_shape

Input shape

integer, public :: merge_mode = 1

Integer code for fundamental merge method 1 = pointwise 2 = concatenate 3 = reduction 4 = parametric (NOT IMPLEMENTED)

character(len=20), public :: method

Merge method

character(len=:), public, allocatable :: name

Layer name

integer, public :: num_input_layers = 0

Number of input layers

class(array_type), public, allocatable, dimension(:,:) :: output

Output

integer, public :: output_rank = 0

Rank of output data

integer, public, allocatable, dimension(:) :: output_shape

Output shape

character(len=20), public :: subtype = repeat(" ", 20)
character(len=4), public :: type = 'base'

Layer type

logical, public :: use_graph_input = .false.

Use graph input

logical, public :: use_graph_output = .false.

Use graph output

Type-Bound Procedures

procedure, public, pass(this) :: build_from_onnx => build_from_onnx_base

Build layer from ONNX node and initialiser

procedure(calc_input_shape), public, deferred, pass(this) :: calc_input_shape

Calculate input shape based on shapes of input layers

procedure(combine_merge), public, deferred, pass(this) :: combine

Merge two layers (forward)

procedure, public, pass(this) :: emit_onnx_graph_inputs => emit_onnx_graph_inputs_base

Emit graph input tensor declarations for this layer

procedure, public, pass(this) :: emit_onnx_nodes => emit_onnx_nodes_base

Emit ONNX JSON nodes for this layer (format-aware and polymorphic)

procedure, public, pass(this) :: extract_output => extract_output_base

Extract the output of the layer as a standard real array

procedure, public, pass(this) :: forward => forward_base

Forward pass of layer

procedure, public, pass(this) :: forward_eval => forward_eval_base

Forward pass of layer and return output for evaluation

procedure, public, pass(this) :: get_attributes => get_attributes_base

Get the attributes of the layer (for ONNX export)

procedure, public, pass(this) :: get_num_params => get_num_params_base

Get the number of parameters in the layer

procedure(initialise), public, deferred, pass(this) :: init

Initialise the layer

procedure, public, pass(this) :: nullify_graph => nullify_graph_base

Nullify the forward pass data of the layer to free memory

Read more…
procedure, public, pass(this) :: print => print_base

Print the layer to a file with additional information

procedure, public, pass(this) :: print_to_unit => print_to_unit_base

Print the layer to a unit

procedure(read_layer), public, deferred, pass(this) :: read

Read layer from file

procedure, public, pass(this) :: set_graph => set_graph_base

Set the graph structure of the input data !! this is adjacency and edge weighting

procedure, public, pass(this) :: set_rank => set_rank_base

Set the input and output ranks of the layer

procedure, public, pass(this) :: set_shape => set_shape_base

Set the input shape of the layer

type, public, abstract, extends(base_layer_type) ::  pad_layer_type

Type for padding layers

Components

Type Visibility Attributes Name Initial
integer, public, allocatable, dimension(:,:) :: dest_bound

Original and destination bounds

type(facets_type), public, dimension(:), allocatable :: facets

Facets of the layer

type(graph_type), public, allocatable, dimension(:) :: graph

Graph structure of input data

integer, public :: id

Unique identifier

integer, public :: imethod = 0

Method for padding

logical, public :: inference = .false.

Inference mode

integer, public :: input_rank = 0

Rank of input data

integer, public, allocatable, dimension(:) :: input_shape

Input shape

character(len=20), public :: method = 'valid'

Padding method

character(len=:), public, allocatable :: name

Layer name

integer, public :: num_channels

Number of channels

integer, public, allocatable, dimension(:,:) :: orig_bound

Original and destination bounds

class(array_type), public, allocatable, dimension(:,:) :: output

Output

integer, public :: output_rank = 0

Rank of output data

integer, public, allocatable, dimension(:) :: output_shape

Output shape

integer, public, allocatable, dimension(:) :: pad

Padding size

character(len=20), public :: subtype = repeat(" ", 20)
character(len=4), public :: type = 'base'

Layer type

logical, public :: use_graph_input = .false.

Use graph input

logical, public :: use_graph_output = .false.

Use graph output

Type-Bound Procedures

procedure, public, pass(this) :: build_from_onnx => build_from_onnx_base

Build layer from ONNX node and initialiser

procedure, public, pass(this) :: emit_onnx_graph_inputs => emit_onnx_graph_inputs_base

Emit graph input tensor declarations for this layer

procedure, public, pass(this) :: emit_onnx_nodes => emit_onnx_nodes_base

Emit ONNX JSON nodes for this layer (format-aware and polymorphic)

procedure, public, pass(this) :: extract_output => extract_output_base

Extract the output of the layer as a standard real array

procedure, public, pass(this) :: forward => forward_base

Forward pass of layer

procedure, public, pass(this) :: forward_eval => forward_eval_base

Forward pass of layer and return output for evaluation

procedure, public, pass(this) :: get_attributes => get_attributes_base

Get the attributes of the layer (for ONNX export)

procedure, public, pass(this) :: get_num_params => get_num_params_base

Get the number of parameters in the layer

procedure, public, pass(this) :: init => init_pad

Initialise the layer

procedure, public, pass(this) :: nullify_graph => nullify_graph_base

Nullify the forward pass data of the layer to free memory

Read more…
procedure, public, pass(this) :: print => print_base

Print the layer to a file with additional information

procedure, public, pass(this) :: print_to_unit => print_to_unit_pad

Print layer to unit

procedure(read_layer), public, deferred, pass(this) :: read

Read layer from file

procedure, public, pass(this) :: set_graph => set_graph_base

Set the graph structure of the input data !! this is adjacency and edge weighting

procedure, public, pass(this) :: set_rank => set_rank_base

Set the input and output ranks of the layer

procedure, public, pass(this) :: set_shape => set_shape_base

Set the input shape of the layer

type, public, abstract, extends(base_layer_type) ::  pool_layer_type

Type for pooling layers

Components

Type Visibility Attributes Name Initial
type(graph_type), public, allocatable, dimension(:) :: graph

Graph structure of input data

integer, public :: id

Unique identifier

logical, public :: inference = .false.

Inference mode

integer, public :: input_rank = 0

Rank of input data

integer, public, allocatable, dimension(:) :: input_shape

Input shape

character(len=:), public, allocatable :: name

Layer name

integer, public :: num_channels

Number of channels

class(array_type), public, allocatable, dimension(:,:) :: output

Output

integer, public :: output_rank = 0

Rank of output data

integer, public, allocatable, dimension(:) :: output_shape

Output shape

class(pad_layer_type), public, allocatable :: pad_layer

Padding layer

integer, public, allocatable, dimension(:) :: pool

Pooling and stride sizes

integer, public, allocatable, dimension(:) :: strd

Pooling and stride sizes

character(len=20), public :: subtype = repeat(" ", 20)
character(len=4), public :: type = 'base'

Layer type

logical, public :: use_graph_input = .false.

Use graph input

logical, public :: use_graph_output = .false.

Use graph output

Type-Bound Procedures

procedure, public, pass(this) :: build_from_onnx => build_from_onnx_base

Build layer from ONNX node and initialiser

procedure, public, pass(this) :: emit_onnx_graph_inputs => emit_onnx_graph_inputs_base

Emit graph input tensor declarations for this layer

procedure, public, pass(this) :: emit_onnx_nodes => emit_onnx_nodes_base

Emit ONNX JSON nodes for this layer (format-aware and polymorphic)

procedure, public, pass(this) :: extract_output => extract_output_base

Extract the output of the layer as a standard real array

procedure, public, pass(this) :: forward => forward_base

Forward pass of layer

procedure, public, pass(this) :: forward_eval => forward_eval_base

Forward pass of layer and return output for evaluation

procedure, public, pass(this) :: get_attributes => get_attributes_pool

Get the attributes of the layer (for ONNX export)

procedure, public, pass(this) :: get_num_params => get_num_params_base

Get the number of parameters in the layer

procedure, public, pass(this) :: init => init_pool

Initialise the layer

procedure, public, pass(this) :: nullify_graph => nullify_graph_base

Nullify the forward pass data of the layer to free memory

Read more…
procedure, public, pass(this) :: print => print_base

Print the layer to a file with additional information

procedure, public, pass(this) :: print_to_unit => print_to_unit_pool

Print layer to unit

procedure(read_layer), public, deferred, pass(this) :: read

Read layer from file

procedure, public, pass(this) :: set_graph => set_graph_base

Set the graph structure of the input data !! this is adjacency and edge weighting

procedure, public, pass(this) :: set_rank => set_rank_base

Set the input and output ranks of the layer

procedure, public, pass(this) :: set_shape => set_shape_base

Set the input shape of the layer