athena__activation_linear Module

Module containing implementation of the linear activation function

This module implements a scaled linear (affine) activation function.

Mathematical operation:

where is a scaling factor (typically )

Derivative:

Properties: Linear transformation, no non-linearity introduced Used for regression outputs or when no activation is desired


Uses


Interfaces

public interface linear_actv_type

  • private function initialise(scale, attributes) result(activation)

    Initialise a linear activation function

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real32), intent(in), optional :: scale

    Optional scale factor for activation output

    type(onnx_attribute_type), intent(in), optional, dimension(:) :: attributes

    Optional array of ONNX attributes

    Return Value type(linear_actv_type)

    Linear activation type


Derived Types

type, public, extends(base_actv_type) ::  linear_actv_type

Components

Type Visibility Attributes Name Initial
logical, public :: apply_scaling = .false.

Boolean to apply scaling or not

character(len=10), public :: name

Name of the activation function

real(kind=real32), public :: scale = 1._real32

Scale of the activation function

real(kind=real32), public :: threshold

Threshold of the activation function

Constructor

private function initialise (scale, attributes)

Initialise a linear activation function

Type-Bound Procedures

procedure, public, pass(this) :: apply => apply_linear
procedure, public, pass(this) :: apply_attributes => apply_attributes_linear
procedure, public, pass(this) :: export_attributes => export_attributes_linear
procedure, public, pass(this) :: print_to_unit => print_to_unit_actv
procedure, public, pass(this) :: reset => reset_linear

Functions

public function create_from_onnx_linear_activation(attributes) result(activation)

Create linear activation function from ONNX attributes

Arguments

Type IntentOptional Attributes Name
type(onnx_attribute_type), intent(in), dimension(:) :: attributes

Array of ONNX attributes

Return Value class(base_actv_type), allocatable

Instance of activation type

private function apply_linear(this, val) result(output)

Apply linear activation to 1D array

Read more…

Arguments

Type IntentOptional Attributes Name
class(linear_actv_type), intent(in) :: this

Linear activation type

type(array_type), intent(in) :: val

Input values

Return Value type(array_type), pointer

Scaled output values

private pure function export_attributes_linear(this) result(attributes)

Export linear activation function attributes as ONNX attributes

Arguments

Type IntentOptional Attributes Name
class(linear_actv_type), intent(in) :: this

Linear activation type

Return Value type(onnx_attribute_type), allocatable, dimension(:)

Array of ONNX attributes

private function initialise(scale, attributes) result(activation)

Initialise a linear activation function

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(in), optional :: scale

Optional scale factor for activation output

type(onnx_attribute_type), intent(in), optional, dimension(:) :: attributes

Optional array of ONNX attributes

Return Value type(linear_actv_type)

Linear activation type


Subroutines

private subroutine apply_attributes_linear(this, attributes)

Load ONNX attributes into linear activation function

Arguments

Type IntentOptional Attributes Name
class(linear_actv_type), intent(inout) :: this

Linear activation type

type(onnx_attribute_type), intent(in), dimension(:) :: attributes

Array of ONNX attributes

private pure subroutine reset_linear(this)

Reset linear activation function attributes and variables

Arguments

Type IntentOptional Attributes Name
class(linear_actv_type), intent(inout) :: this

Linear activation type