|
FNN 1.0.0
Toolbox to use NNs in Fortran.
|
Module dedicated to the class denselayer. More...
Data Types | |
| type | denselayer |
| Implements a dense (fully-connected) layer. More... | |
Functions/Subroutines | |
| type(denselayer) function, public | construct_dense_layer (input_size, output_size, batch_size, activation_name, initialisation_name) |
| Manual constructor for class denselayer. Only for testing purpose. More... | |
| type(denselayer) function, public | dense_layer_fromfile (batch_size, unit_num) |
| Constructor for class denselayer from a file. More... | |
| subroutine | dense_tofile (self, unit_num) |
| Implements denselayer::tofile. More... | |
| subroutine | dense_apply_forward (self, train, member, x, y) |
| Implements denselayer::apply_forward. More... | |
| subroutine | dense_apply_tangent_linear (self, member, dp, dx, dy) |
| Implements denselayer::apply_tangent_linear. More... | |
| subroutine | dense_apply_adjoint (self, member, dy, dp, dx) |
| Implements denselayer::apply_adjoint. More... | |
Module dedicated to the class denselayer.
| type(denselayer) function, public fnn_layer_dense::construct_dense_layer | ( | integer(ik), intent(in) | input_size, |
| integer(ik), intent(in) | output_size, | ||
| integer(ik), intent(in) | batch_size, | ||
| character(len=*), intent(in) | activation_name, | ||
| character(len=*), intent(in) | initialisation_name | ||
| ) |
Manual constructor for class denselayer. Only for testing purpose.
| [in] | input_size | The value for layer::input_size. |
| [in] | output_size | The value for layer::output_size. |
| [in] | batch_size | The value for layer::batch_size. |
| [in] | activation_name | The activation function. |
| [in] | initialisation_name | The initialisation for model parameters. |
|
private |
Implements denselayer::apply_adjoint.
Applies the adjoint of the layer.
The adjoint operator is implemented by
![\[d\mathbf{y} = \mathbf{A}(\mathbf{Wx+b})^{\top}d\mathbf{y},\]](form_36.png)
![\[d\mathbf{b} = d\mathbf{y},\]](form_37.png)
![\[d\mathbf{W} = d\mathbf{yx}^{\top},\]](form_38.png)
![\[d\mathbf{x} = \mathbf{W}^{\top}d\mathbf{y}.\]](form_39.png)
Note
This method should only be called after denselayer::apply_forward.
The value of 
![\[d\mathbf{b} = \mathbf{A}(\mathbf{Wx+b})^{\top}d\mathbf{y}.\]](form_41.png)
For this reason, the intent of dy is declared inout.
| [in,out] | self | The layer. |
| [in] | member | The index inside the batch. |
| [in,out] | dy | The output perturbation. |
| [out] | dp | The parameter perturbation. |
| [out] | dx | The state perturbation. |
|
private |
Implements denselayer::apply_forward.
Applies and linearises the layer.
The forward function reads
![\[ \mathbf{y} = \mathcal{F}(\mathbf{p}, \mathbf{x})
= \mathcal{A}(\mathbf{Wx+b}),\]](form_28.png)
where 


Note
Input parameter member should be less than layer::batch_size.
The linearisation of the regression 
Because the linearisation of the layer is stored inside the layer, the intent of selfis declared inout.
| [in,out] | self | The layer. |
| [in] | train | Whether the model is used in training mode. |
| [in] | member | The index inside the batch. |
| [in] | x | The input of the layer. |
| [out] | y | The output of the layer. |
|
private |
Implements denselayer::apply_tangent_linear.
Applies the TL of the layer.
The TL operator reads
![\[d\mathbf{y} = \mathbf{A}(\mathbf{Wx+b})[\mathbf{W}d
\mathbf{x}+d\mathbf{Wx}+d\mathbf{b}],\]](form_31.png)
which is implemented by
![\[d\mathbf{y} = \mathbf{W}d\mathbf{x},\]](form_32.png)
![\[d\mathbf{y} = d\mathbf{y} + d\mathbf{Wx},\]](form_33.png)
![\[d\mathbf{y} = d\mathbf{y} + d\mathbf{b},\]](form_34.png)
![\[d\mathbf{y} = \mathbf{A}(\mathbf{Wx+b})d\mathbf{y}.\]](form_35.png)
Note
This method should only be called after denselayer::apply_forward.
| [in] | self | The layer. |
| [in] | member | The index inside the batch. |
| [in] | dp | The parameter perturbation. |
| [in] | dx | The state perturbation. |
| [out] | dy | The output perturbation. |
| type(denselayer) function, public fnn_layer_dense::dense_layer_fromfile | ( | integer(ik), intent(in) | batch_size, |
| integer(ik), intent(in) | unit_num | ||
| ) |
Constructor for class denselayer from a file.
| [in] | batch_size | The value for layer::batch_size. |
| [in] | unit_num | The unit number for the read statements. |
|
private |
Implements denselayer::tofile.
Saves the layer.
| [in] | self | The layer. |
| [in] | unit_num | The unit number for the write statement. |