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

Module dedicated to the class tanhactivation. More...

Data Types

type  tanhactivation
 Implements a tanh activation function. More...
 

Functions/Subroutines

type(tanhactivation) function, public construct_tanh_activation (self_size, batch_size)
 Constructor for class tanhactivation. More...
 
subroutine tanh_tofile (self, unit_num)
 Implements tanhactivation::tofile. More...
 
subroutine tanh_apply_forward (self, member, z, y)
 Implements tanhactivation::apply_forward. More...
 

Detailed Description

Module dedicated to the class tanhactivation.

Function/Subroutine Documentation

◆ construct_tanh_activation()

type(tanhactivation) function, public fnn_activation_tanh::construct_tanh_activation ( integer(ik), intent(in)  self_size,
integer(ik), intent(in)  batch_size 
)

Constructor for class tanhactivation.

Parameters
[in]self_sizeThe value for linearactivation::self_size.
[in]batch_sizeThe value for linearactivation::batch_size.
Returns
The constructed activation function.

◆ tanh_apply_forward()

subroutine fnn_activation_tanh::tanh_apply_forward ( class(tanhactivation), intent(inout)  self,
integer(ik), intent(in)  member,
real(rk), dimension(:), intent(in)  z,
real(rk), dimension(:), intent(out)  y 
)
private

Implements tanhactivation::apply_forward.

Applies and linearises the activation function.

The activation function reads

\[ \mathbf{y} = \mathcal{A}(\mathbf{z}) = \mathrm{tanh}(\mathbf{z}),\]

and the associated linearisation reads

\[ \mathbf{A}(\mathbf{z}) = \mathrm{diag}(1-\mathrm{tanh}(\mathbf{z})^2).\]

Note

Input parameter member should be less than linearactivation::batch_size.

The linarisation is stored in nonlinearactivation::z_prime, which is why the intent of self is declared inout.

Parameters
[in,out]selfThe activation function.
[in]memberThe index inside the batch.
[in]zThe input of the activation function.
[out]yThe output of the activation function.

◆ tanh_tofile()

subroutine fnn_activation_tanh::tanh_tofile ( class(tanhactivation), intent(in)  self,
integer(ik), intent(in)  unit_num 
)
private

Implements tanhactivation::tofile.

Saves the activation function.

Parameters
[in]selfThe activation function to save.
[in]unit_numThe unit number for the write statement.