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
Add two layers
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(learnable_layer_type), | intent(in) | :: | a |
Instances of the layers |
||
| class(learnable_layer_type), | intent(in) | :: | b |
Instances of the layers |
Output layer
Build layer from ONNX node
| Type | Intent | Optional | 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 |
Calculate input shape based on shapes of input layers
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(merge_layer_type), | intent(in) | :: | this |
Instance of the layer |
||
| integer, | intent(in), | dimension(:,:) | :: | input_shapes |
Input shapes |
Calculated input shape
Combine two layers (forward)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(merge_layer_type), | intent(inout) | :: | this |
Instance of the layer |
||
| type(array_ptr_type), | intent(in), | dimension(:) | :: | input_list |
Input values |
Emit graph input tensor declarations for this layer Default implementation does nothing; override for GNN layers
| Type | Intent | Optional | 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 |
Emit ONNX JSON nodes for this layer Default implementation does nothing; override for GNN/NOP layers
| Type | Intent | Optional | 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 |
Extract the output of the layer as a standard real array
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(base_layer_type), | intent(in) | :: | this |
Instance of the layer |
||
| real(kind=real32), | intent(out), | dimension(..), allocatable | :: | output |
Output values |
Forward pass of layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(base_layer_type), | intent(inout) | :: | this |
Instance of the layer |
||
| class(array_type), | intent(in), | dimension(:,:) | :: | input |
Input data |
Forward pass of layer and return output for evaluation
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(base_layer_type), | intent(inout), | target | :: | this |
Instance of the layer |
|
| class(array_type), | intent(in), | dimension(:,:) | :: | input |
Input data |
Output data
Get the attributes of the layer (for ONNX export)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(base_layer_type), | intent(in) | :: | this |
Instance of the layer |
Attributes of the layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(batch_layer_type), | intent(in) | :: | this |
Instance of the layer |
Attributes of the layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(conv_layer_type), | intent(in) | :: | this |
Get the attributes of the layer (for ONNX export)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(pool_layer_type), | intent(in) | :: | this |
Instance of the layer |
Attributes of the layer
Get parameter gradients of layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(learnable_layer_type), | intent(in) | :: | this |
Instance of the layer |
||
| type(clip_type), | intent(in), | optional | :: | clip_method |
Clip method |
Parameter gradients
Get number of parameters in layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(base_layer_type), | intent(in) | :: | this |
Instance of the layer |
Number of parameters
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(base_layer_type), | intent(in) | :: | this |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(batch_layer_type), | intent(in) | :: | this |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(conv_layer_type), | intent(in) | :: | this |
Get learnable parameters of layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(learnable_layer_type), | intent(in) | :: | this |
Instance of the layer |
Learnable parameters
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(batch_layer_type), | intent(inout) | :: | this | |||
| integer, | intent(in), | dimension(:) | :: | input_shape | ||
| integer, | intent(in), | optional | :: | verbose |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(conv_layer_type), | intent(inout) | :: | this | |||
| integer, | intent(in), | dimension(:) | :: | input_shape | ||
| integer, | intent(in), | optional | :: | verbose |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(pad_layer_type), | intent(inout) | :: | this | |||
| integer, | intent(in), | dimension(:) | :: | input_shape | ||
| integer, | intent(in), | optional | :: | verbose |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(pool_layer_type), | intent(inout) | :: | this | |||
| integer, | intent(in), | dimension(:) | :: | input_shape | ||
| integer, | intent(in), | optional | :: | verbose |
Initialise the layer
| Type | Intent | Optional | 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 |
Nullify the forward pass data of the layer to free memory
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(base_layer_type), | intent(inout) | :: | this |
Instance of the layer |
Print the layer to a file with additional information
| Type | Intent | Optional | 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 |
Print the layer to a file
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(base_layer_type), | intent(in) | :: | this |
Instance of the layer |
||
| integer, | intent(in) | :: | unit |
File unit |
Print layer to unit
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(batch_layer_type), | intent(in) | :: | this |
Instance of the layer |
||
| integer, | intent(in) | :: | unit |
File unit |
Print layer to unit
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(conv_layer_type), | intent(in) | :: | this |
Instance of the layer |
||
| integer, | intent(in) | :: | unit |
File unit |
Print layer to unit
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(pad_layer_type), | intent(in) | :: | this |
Instance of the layer |
||
| integer, | intent(in) | :: | unit |
File unit |
Print layer to unit
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(pool_layer_type), | intent(in) | :: | this |
Instance of the layer |
||
| integer, | intent(in) | :: | unit |
File unit |
Read layer from file
| Type | Intent | Optional | 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 |
Merge another learnable layer into this one
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(learnable_layer_type), | intent(inout) | :: | this |
Instance of the layer |
||
| class(learnable_layer_type), | intent(in) | :: | input |
Other layer to merge |
Set learnable parameters of layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(learnable_layer_type), | intent(inout) | :: | this |
Instance of the layer |
||
| real(kind=real32), | intent(in), | dimension(..) | :: | gradients |
Learnable parameters |
Set the graph structure of the input data
| Type | Intent | Optional | 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 |
Set learnable parameters of layer
| Type | Intent | Optional | 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 |
Set the input and output ranks of the layer
| Type | Intent | Optional | 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 |
Set the input shape of the layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(base_layer_type), | intent(inout) | :: | this |
Instance of the layer |
||
| integer, | intent(in), | dimension(:) | :: | input_shape |
Input shape |
Generate dropout mask
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(drop_layer_type), | intent(inout) | :: | this |
Instance of the layer |
Type for base layer, from which all other layers are derived
| 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 |
| 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 |
| 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 for batch normalisation layers
| 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 |
| 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 |
| 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 | 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 |
| 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 |
| 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 for dropout layers
| 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 |
| 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 |
| 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 for layers with learnable parameters
| 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 |
| 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 |
| 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 for merge layers (i.e. add, multiply, concatenate)
| 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 |
| 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 |
| 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 for padding layers
| 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 |
| 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 |
| 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 for pooling layers
| 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 |
| 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 |
| 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 |