leaky_relu_activate Function

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

Apply leaky ReLU activation to 1D array

Computes: f = max(0.01x, x)

Type Bound

leaky_relu_actv_type

Arguments

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

Leaky ReLU activation type

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

Input values

Return Value type(array_type), pointer

Activated output values


Source Code

  function leaky_relu_activate(this, val) result(output)
    !! Apply leaky ReLU activation to 1D array
    !!
    !! Computes: f = max(0.01x, x)
    implicit none

    ! Arguments
    class(leaky_relu_actv_type), intent(in) :: this
    !! Leaky ReLU activation type
    type(array_type), intent(in) :: val
    !! Input values
    type(array_type), pointer :: output
    !! Activated output values

    ! allocate(output)
    if(this%apply_scaling)then
       output => max(val * this%alpha, val) * this%scale
    else
       output => max(val * this%alpha, val)
    end if
  end function leaky_relu_activate