athena__activation_piecewise Module

Module containing implementation of the piecewise activation function https://doi.org/10.48550/arXiv.1809.09534


Uses


Interfaces

public interface piecewise_actv_type

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

    Initialise a piecewise activation function

    Arguments

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

    Optional scale factor for activation output

    real(kind=real32), intent(in), optional :: gradient

    Optional gradient parameter for piecewise function

    real(kind=real32), intent(in), optional :: limit

    Optional limit parameter for piecewise function -limit < x < limit

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

    Optional array of ONNX attributes

    Return Value type(piecewise_actv_type)

    Piecewise activation type


Derived Types

type, public, extends(base_actv_type) ::  piecewise_actv_type

Type for piecewise activation function with overloaded procedures

Components

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

Boolean to apply scaling or not

real(kind=real32), public :: gradient
real(kind=real32), public :: limit
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, gradient, limit, attributes)

Initialise a piecewise activation function

Type-Bound Procedures

procedure, public, pass(this) :: apply => apply_piecewise
procedure, public, pass(this) :: apply_attributes => apply_attributes_piecewise
procedure, public, pass(this) :: export_attributes => export_attributes_piecewise
procedure, public, pass(this) :: print_to_unit => print_to_unit_actv
procedure, public, pass(this) :: reset => reset_piecewise

Functions

public function create_from_onnx_piecewise_activation(attributes) result(activation)

Create piecewise 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_piecewise(this, val) result(output)

Apply piecewise activation to 1D array

Read more…

Arguments

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

Piecewise activation type

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

Input values

Return Value type(array_type), pointer

Activated output values

private pure function export_attributes_piecewise(this) result(attributes)

Export piecewise activation function attributes as ONNX attributes

Arguments

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

Piecewise activation type

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

Array of ONNX attributes

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

Initialise a piecewise activation function

Arguments

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

Optional scale factor for activation output

real(kind=real32), intent(in), optional :: gradient

Optional gradient parameter for piecewise function

real(kind=real32), intent(in), optional :: limit

Optional limit parameter for piecewise function -limit < x < limit

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

Optional array of ONNX attributes

Return Value type(piecewise_actv_type)

Piecewise activation type


Subroutines

private subroutine apply_attributes_piecewise(this, attributes)

Load ONNX attributes into piecewise activation function

Arguments

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

Piecewise activation type

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

Array of ONNX attributes

private pure subroutine reset_piecewise(this)

Reset piecewise activation function attributes and variables

Arguments

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

Piecewise activation type