FNN 1.0.0
Toolbox to use NNs in Fortran.
Loading...
Searching...
No Matches
Data Types | Functions/Subroutines
fnn_network_sequential Module Reference

Module dedicated to the class sequentialneuralnetwork. More...

Data Types

type  layercontainer
 Layer container class. More...
 
type  sequentialneuralnetwork
 Implements a sequential neural network. More...
 

Functions/Subroutines

type(sequentialneuralnetwork) function, public construct_sequential_neural_network (batch_size, internal_sizes, activation_names, initialisation_names)
 Manual constructor for class sequentialneuralnetwork. Only for testing purpose. More...
 
type(sequentialneuralnetwork) function, public snn_fromfile (batch_size, filename)
 Constructor for class sequentialneuralnetwork from a file. More...
 
integer(ik) function snn_get_input_size (self)
 Implements sequentialneuralnetwork::get_input_size. More...
 
integer(ik) function snn_get_output_size (self)
 Implements sequentialneuralnetwork::get_output_size. More...
 
integer(ik) function snn_get_num_parameters (self)
 Implements sequentialneuralnetwork::get_num_parameters. More...
 
subroutine snn_set_parameters (self, new_parameters)
 Implements sequentialneuralnetwork::set_parameters. More...
 
subroutine snn_get_parameters (self, parameters)
 Implements sequentialneuralnetwork::get_parameters. More...
 
subroutine snn_tofile (self, filename)
 Implements sequentialneuralnetwork::tofile. More...
 
subroutine snn_apply_forward (self, train, member, x, y)
 Implements sequentialneuralnetwork::apply_forward. More...
 
subroutine snn_apply_tangent_linear (self, member, dp, dx, dy)
 Implements sequentialneuralnetwork::apply_tangent_linear. More...
 
subroutine snn_apply_adjoint (self, member, dy, dp, dx)
 Implements sequentialneuralnetwork::apply_adjoint. More...
 

Detailed Description

Module dedicated to the class sequentialneuralnetwork.

Function/Subroutine Documentation

◆ construct_sequential_neural_network()

type(sequentialneuralnetwork) function, public fnn_network_sequential::construct_sequential_neural_network ( integer(ik), intent(in)  batch_size,
integer(ik), dimension(:), intent(in)  internal_sizes,
character(len=*), dimension(:), intent(in)  activation_names,
character(len=*), dimension(:), intent(in)  initialisation_names 
)

Manual constructor for class sequentialneuralnetwork. Only for testing purpose.

Parameters
[in]batch_sizeThe value for sequentialneuralnetwork::batch_size.
[in]internal_sizesThe list of internal sizes.
[in]activation_namesThe list of activation functions.
[in]initialisation_namesThe list of initialisations for model parameters.
Returns
The constructed network.

◆ snn_apply_adjoint()

subroutine fnn_network_sequential::snn_apply_adjoint ( class(sequentialneuralnetwork), intent(inout)  self,
integer(ik), intent(in)  member,
real(rk), dimension(:), intent(inout)  dy,
real(rk), dimension(:), intent(out)  dp,
real(rk), dimension(:), intent(out)  dx 
)
private

Implements sequentialneuralnetwork::apply_adjoint.

Applies the adjoint of the network.

Note

If there is more than one layer, this method uses layer::adjoint_input as intermediate storage.

For this reason, the intent of self is declared inout. In addition, the intent of dy is declared intout because for certain layer classes (e.g. fnn_layer_dense::denselayer) the output perturbation gets overwritten in the process.

Parameters
[in,out]selfThe network.
[in]memberThe index inside the batch.
[in,out]dyThe output perturbation.
[out]dpThe parameter perturbation.
[out]dxThe state perturbation.

◆ snn_apply_forward()

subroutine fnn_network_sequential::snn_apply_forward ( class(sequentialneuralnetwork), intent(inout)  self,
logical, intent(in)  train,
integer(ik), intent(in)  member,
real(rk), dimension(:), intent(in)  x,
real(rk), dimension(:), intent(out)  y 
)
private

Implements sequentialneuralnetwork::apply_forward.

Applies and linearises the network.

Note

If there is more than one layer, this method uses layer::forward_input as intermediate storage.

For the case of a fnn_layer_dense::denselayer, this means that the first step of denselayer::apply_forward consists in copying layer::forward_input into... layer::forward_input!

For theses reasons, and because the linearisation is stored inside the network, the intent of self is declared inout.

Parameters
[in,out]selfThe network.
[in]trainWhether the model is used in training mode.
[in]memberThe index inside the batch.
[in]xThe input of the network.
[out]yThe output of the network.

◆ snn_apply_tangent_linear()

subroutine fnn_network_sequential::snn_apply_tangent_linear ( class(sequentialneuralnetwork), intent(inout)  self,
integer(ik), intent(in)  member,
real(rk), dimension(:), intent(in)  dp,
real(rk), dimension(:), intent(in)  dx,
real(rk), dimension(:), intent(out)  dy 
)
private

Implements sequentialneuralnetwork::apply_tangent_linear.

Applies the TL of the network.

Note

If there is more than one layer, this method uses layer::tangent_linear_input as intermediate storage.

For this reason, the intent of self is declared inout.

Parameters
[in,out]selfThe network.
[in]memberThe index inside the batch.
[in]dpThe parameter perturbation.
[in]dxThe state perturbation.
[out]dyThe output perturbation.

◆ snn_fromfile()

type(sequentialneuralnetwork) function, public fnn_network_sequential::snn_fromfile ( integer(ik), intent(in)  batch_size,
character(len=*), intent(in)  filename 
)

Constructor for class sequentialneuralnetwork from a file.

Parameters
[in]batch_sizeThe value for layer::batch_size.
[in]filenameThe name of the file to read.
Returns
The constructed network.

◆ snn_get_input_size()

integer(ik) function fnn_network_sequential::snn_get_input_size ( class(sequentialneuralnetwork), intent(in)  self)
private

Implements sequentialneuralnetwork::get_input_size.

Returns the input size of the network.

Parameters
[in]selfThe network.
Returns
The input size.

◆ snn_get_num_parameters()

integer(ik) function fnn_network_sequential::snn_get_num_parameters ( class(sequentialneuralnetwork), intent(in)  self)
private

Implements sequentialneuralnetwork::get_num_parameters.

Returns the number of parameters.

Parameters
[in]selfThe network.
Returns
The number of parameters.

◆ snn_get_output_size()

integer(ik) function fnn_network_sequential::snn_get_output_size ( class(sequentialneuralnetwork), intent(in)  self)
private

Implements sequentialneuralnetwork::get_output_size.

Returns the output size of the network.

Parameters
[in]selfThe network.
Returns
The output size.

◆ snn_get_parameters()

subroutine fnn_network_sequential::snn_get_parameters ( class(sequentialneuralnetwork), intent(in)  self,
real(rk), dimension(:), intent(out)  parameters 
)
private

Implements sequentialneuralnetwork::get_parameters.

Getter for the network's parameters.

Parameters
[in]selfThe network.
[out]parametersThe vector of parameters.

◆ snn_set_parameters()

subroutine fnn_network_sequential::snn_set_parameters ( class(sequentialneuralnetwork), intent(inout)  self,
real(rk), dimension(:), intent(in)  new_parameters 
)
private

Implements sequentialneuralnetwork::set_parameters.

Setter for the network's parameters.

Parameters
[in,out]selfThe network.
[in]new_parametersThe new values for the parameters.

◆ snn_tofile()

subroutine fnn_network_sequential::snn_tofile ( class(sequentialneuralnetwork), intent(in)  self,
character(len=*), intent(in)  filename 
)
private

Implements sequentialneuralnetwork::tofile.

Saves the network.

Parameters
[in]selfThe network.
[in]filenameThe name of the file to write.