apply_relu Function

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

Apply ReLU activation to 1D array

Computes: f = max(0,x)

Type Bound

relu_actv_type

Arguments

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

ReLU activation type

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

Input values

Return Value type(array_type), pointer

Activated output values


Source Code

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

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

    if(this%apply_scaling)then
       output => max(val, this%threshold) * this%scale
    else
       output => max(val, this%threshold)
    end if
  end function apply_relu