apply_linear Function

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

Apply linear activation to 1D array

Computes: f = scale * x

Type Bound

linear_actv_type

Arguments

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

Linear activation type

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

Input values

Return Value type(array_type), pointer

Scaled output values


Source Code

  function apply_linear(this, val) result(output)
    !! Apply linear activation to 1D array
    !!
    !! Computes: f = scale * x
    implicit none

    ! Arguments
    class(linear_actv_type), intent(in) :: this
    !! Linear activation type
    type(array_type), intent(in) :: val
    !! Input values
    type(array_type), pointer :: output
    !! Scaled output values

    if(this%apply_scaling)then
       output => val * this%scale
    else
       output => val * 1._real32 ! multiplication by 1 to ensure new allocation
    end if
  end function apply_linear