initialise Function

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


Source Code

  function initialise(scale, gradient, limit, attributes) result(activation)
    !! Initialise a piecewise activation function
    implicit none

    ! Arguments
    real(real32), intent(in), optional :: scale
    !! Optional scale factor for activation output
    real(real32), intent(in), optional :: gradient
    !! Optional gradient parameter for piecewise function
    real(real32), intent(in), optional :: limit
    !! Optional limit parameter for piecewise function
    !! -limit < x < limit
    type(onnx_attribute_type), dimension(:), intent(in), optional :: attributes
    !! Optional array of ONNX attributes
    type(piecewise_actv_type) :: activation
    !! Piecewise activation type


    call activation%reset()

    if(present(scale)) activation%scale = scale
    if(abs(activation%scale-1._real32) .gt. 1.e-6_real32)then
       activation%apply_scaling = .true.
    end if

    if(present(gradient)) activation%gradient = gradient
    if(present(limit)) activation%limit = limit

    if(present(attributes))then
       call activation%apply_attributes(attributes)
    end if

  end function initialise