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

Module dedicated to the class linearactivation. More...

Data Types

type  linearactivation
 Base class for all activation functions. Implements a linear activation function. More...
 

Functions/Subroutines

type(linearactivation) function, public construct_linear_activation (self_size, batch_size)
 Constructor for class linearactivation. More...
 
subroutine linear_tofile (self, unit_num)
 Implements linearactivation::tofile. More...
 
subroutine linear_apply_forward (self, member, z, y)
 Implements linearactivation::apply_forward. More...
 
subroutine linear_apply_tangent_linear (self, member, dz, dy)
 Implements linearactivation::apply_tangent_linear. More...
 
subroutine linear_apply_adjoint (self, member, dy, dz)
 Implements linearactivation::apply_adjoint. More...
 

Detailed Description

Module dedicated to the class linearactivation.

Function/Subroutine Documentation

◆ construct_linear_activation()

type(linearactivation) function, public fnn_activation_linear::construct_linear_activation ( integer(ik), intent(in)  self_size,
integer(ik), intent(in)  batch_size 
)

Constructor for class linearactivation.

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

◆ linear_apply_adjoint()

subroutine fnn_activation_linear::linear_apply_adjoint ( class(linearactivation), intent(in)  self,
integer(ik), intent(in)  member,
real(rk), dimension(:), intent(in)  dy,
real(rk), dimension(:), intent(out)  dz 
)
private

Implements linearactivation::apply_adjoint.

Applies the adjoint of the activation function.

The adjoint operator reads

\[ d\mathbf{z} = \mathbf{A}(\mathbf{z})^\top d\mathbf{y} = d\mathbf{y}.\]

Note

In principle, this method should only be called after linearactivation::apply_forward, where the linearisation is computed.

This method supports inplace operations: it can be called with dz = dy.

Parameters
[in]selfThe activation function.
[in]memberThe index inside the batch.
[in]dyThe input of the adjoint operator.
[out]dzThe output of the adjoint operator.

◆ linear_apply_forward()

subroutine fnn_activation_linear::linear_apply_forward ( class(linearactivation), intent(inout)  self,
integer(ik), intent(in)  member,
real(rk), dimension(:), intent(in)  z,
real(rk), dimension(:), intent(out)  y 
)
private

Implements linearactivation::apply_forward.

Applies and linearises the activation function.

The activation function reads

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

and the associated linearisation reads

\[ \mathbf{A}(\mathbf{z}) = \mathbf{I},\]

which is trivial and does not require any operation.

Note

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

This method supports inplace operations: it can be called with y = z.

The intent for self is declared inout instead of in because, for certain subclasses (e.g. fnn_activation_tanh::tanhactivation) the linearisation is stored inside the activation function.

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.

◆ linear_apply_tangent_linear()

subroutine fnn_activation_linear::linear_apply_tangent_linear ( class(linearactivation), intent(in)  self,
integer(ik), intent(in)  member,
real(rk), dimension(:), intent(in)  dz,
real(rk), dimension(:), intent(out)  dy 
)
private

Implements linearactivation::apply_tangent_linear.

Applies the TL of the activation function.

The TL operator reads

\[ d\mathbf{y} = \mathbf{A}(\mathbf{z}) d\mathbf{z} = d\mathbf{z}.\]

Note

In principle, this method should only be called after linearactivation::apply_forward, where the linearisation is computed.

This method supports inplace operations: it can be called with dy = dz.

Parameters
[in]selfThe activation function.
[in]memberThe index inside the batch.
[in]dzThe input of the TL operator.
[out]dyThe output of the TL operator.

◆ linear_tofile()

subroutine fnn_activation_linear::linear_tofile ( class(linearactivation), intent(in)  self,
integer(ik), intent(in)  unit_num 
)
private

Implements linearactivation::tofile.

Saves the activation function.

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