apply_swish Function

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

Apply swish activation to 1D array

Computes: f(x) = x * sigmoid(βx) = x / (1 + exp(-βx))

Type Bound

swish_actv_type

Arguments

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

Swish activation type

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

Input values

Return Value type(array_type), pointer

Swish activation output


Source Code

  function apply_swish(this, val) result(output)
    !! Apply swish activation to 1D array
    !!
    !! Computes: f(x) = x * sigmoid(β*x) = x / (1 + exp(-β*x))
    implicit none

    ! Arguments
    class(swish_actv_type), intent(in) :: this
    !! Swish activation type
    type(array_type), intent(in) :: val
    !! Input values
    type(array_type), pointer :: output
    !! Swish activation output

    ! Compute sigmoid(β*x)
    ! Compute swish: x * sigmoid(β*x)
    if(this%apply_scaling)then
       output => swish(val, this%beta) * this%scale
    else
       output => swish(val, this%beta)
    end if
  end function apply_swish