Module containing implementation of a Laplace Neural Operator layer
This module implements a Laplace Neural Operator (LNO) layer that approximates an integral kernel operator in the Laplace-transform domain. It combines a spectral pathway (encode → spectral mixing → decode) with a local affine bypass:
where: - is the discretised input - is the Laplace encoder basis: , , - are learnable spectral mixing weights - is the Laplace decoder basis: , - are the local (bypass) weights - is the bias - is the activation function - = num_modes, the number of Laplace spectral modes
Number of parameters (learnable): without bias, with bias.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | num_outputs | |||
| integer, | intent(in) | :: | num_modes | |||
| integer, | intent(in), | optional | :: | num_inputs | ||
| logical, | intent(in), | optional | :: | use_bias | ||
| class(*), | intent(in), | optional | :: | activation | ||
| class(*), | intent(in), | optional | :: | kernel_initialiser | ||
| class(*), | intent(in), | optional | :: | bias_initialiser | ||
| integer, | intent(in), | optional | :: | verbose |
Type for a fixed-basis Laplace Neural Operator layer
| 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(array_type), | public | :: | decoder_basis |
Fixed Laplace decoder basis D [num_outputs x num_modes] |
|||
| type(array_type), | public | :: | encoder_basis |
Fixed Laplace encoder basis E [num_modes x num_inputs] |
|||
| 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_inputs |
Number of inputs (discretisation points) |
|||
| integer, | public | :: | num_modes |
Number of Laplace spectral modes |
|||
| integer, | public | :: | num_outputs |
Number of outputs (discretisation points) |
|||
| 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(array_type), | public, | dimension(1) | :: | z |
Temporary array for pre-activation values |
| private module function layer_setup (num_outputs, num_modes, num_inputs, use_bias, activation, kernel_initialiser, bias_initialiser, verbose) |
| final :: finalise_fixed_lno |
| 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_fixed_lno | |
| 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_fixed_lno | |
| 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_fixed_lno | |
| procedure, public, pass(this) :: get_gradients | Get parameter gradients of layer |
| procedure, public, pass(this) :: get_num_params => get_num_params_fixed_lno | |
| procedure, public, pass(this) :: get_params | Get learnable parameters of layer |
| procedure, public, pass(this) :: init => init_fixed_lno | |
| 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_fixed_lno | |
| procedure, public, pass(this) :: read => read_fixed_lno | |
| 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_hyperparams => set_hyperparams_fixed_lno | |
| 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 |
Read a fixed LNO layer from file and return it
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | unit |
Input unit number |
||
| integer, | intent(in), | optional | :: | verbose |
Verbosity level |
Allocated base-layer instance containing the result
Return list of fixed LNO attributes for ONNX export
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_lno_layer_type), | intent(in) | :: | this |
Instance of the fixed LNO layer |
List of attributes for ONNX export
Return the number of learnable parameters for the layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_lno_layer_type), | intent(in) | :: | this |
Layer instance |
Total number of learnable parameters
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | num_outputs |
Number of output features |
||
| integer, | intent(in) | :: | num_modes |
Number of Laplace spectral modes |
||
| integer, | intent(in), | optional | :: | num_inputs |
Number of input features when known at construction time |
|
| logical, | intent(in), | optional | :: | use_bias |
Whether to allocate a bias term |
|
| class(*), | intent(in), | optional | :: | activation |
Activation function specification |
|
| class(*), | intent(in), | optional | :: | kernel_initialiser |
Kernel and bias initialiser specifications |
|
| class(*), | intent(in), | optional | :: | bias_initialiser |
Kernel and bias initialiser specifications |
|
| integer, | intent(in), | optional | :: | verbose |
Verbosity level |
Constructed fixed LNO layer
Emit decomposed standard ONNX nodes for a Fixed LNO layer.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_lno_layer_type), | intent(in) | :: | this |
Fixed LNO layer instance |
||
| character(len=*), | intent(in) | :: | prefix |
Layer name prefix (e.g. "layer1") |
||
| type(onnx_node_type), | intent(inout), | dimension(:) | :: | nodes |
Node accumulator |
|
| integer, | intent(inout) | :: | num_nodes |
Node counter |
||
| integer, | intent(in) | :: | max_nodes |
Node limit |
||
| type(onnx_initialiser_type), | intent(inout), | dimension(:) | :: | inits |
Initialiser accumulator |
|
| integer, | intent(inout) | :: | num_inits |
Initialiser counter |
||
| integer, | intent(in) | :: | max_inits |
Initialiser limit |
||
| character(len=*), | intent(in), | optional | :: | input_name |
Name of the input tensor |
|
| logical, | intent(in), | optional | :: | is_last_layer |
Whether this is the last layer |
|
| integer, | intent(in), | optional | :: | format |
Export format selector |
Finalise the fixed-basis Laplace neural operator layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(fixed_lno_layer_type), | intent(inout) | :: | this |
Layer instance to release |
Forward propagation for the Laplace Neural Operator layer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_lno_layer_type), | intent(inout) | :: | this |
Layer instance to execute |
||
| class(array_type), | intent(in), | dimension(:,:) | :: | input |
Input batch tensor collection |
Initialise parameter storage, fixed bases and output buffers
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_lno_layer_type), | intent(inout) | :: | this |
Layer instance to initialise |
||
| integer, | intent(in), | dimension(:) | :: | input_shape |
Input shape used to infer num_inputs |
|
| integer, | intent(in), | optional | :: | verbose |
Verbosity level |
Print fixed LNO settings and parameters to a unit
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_lno_layer_type), | intent(in) | :: | this |
Layer instance to print |
||
| integer, | intent(in) | :: | unit |
Output unit number |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_lno_layer_type), | intent(inout) | :: | this |
Layer instance to populate from file data |
||
| integer, | intent(in) | :: | unit |
Input unit number |
||
| integer, | intent(in), | optional | :: | verbose |
Verbosity level |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(fixed_lno_layer_type), | intent(inout) | :: | this |
Layer instance to configure |
||
| integer, | intent(in) | :: | num_outputs |
Number of output features |
||
| integer, | intent(in) | :: | num_modes |
Number of Laplace spectral modes |
||
| logical, | intent(in) | :: | use_bias |
Whether to use a bias term |
||
| class(base_actv_type), | intent(in), | allocatable | :: | activation |
Activation function object |
|
| class(base_init_type), | intent(in), | allocatable | :: | kernel_initialiser |
Kernel and bias initialiser objects |
|
| class(base_init_type), | intent(in), | allocatable | :: | bias_initialiser |
Kernel and bias initialiser objects |
|
| integer, | intent(in), | optional | :: | verbose |
Verbosity level |