Apply SELU activation to array
Computes: f(x) = λ * x if x > 0 f(x) = λ * α * (exp(x) - 1) if x ≤ 0
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(selu_actv_type), | intent(in) | :: | this |
SELU activation type |
||
| type(array_type), | intent(in) | :: | val |
Input values |
Activated output values
function apply_selu(this, val) result(output) !! Apply SELU activation to array !! !! Computes: f(x) = λ * x if x > 0 !! f(x) = λ * α * (exp(x) - 1) if x ≤ 0 implicit none ! Arguments class(selu_actv_type), intent(in) :: this !! SELU activation type type(array_type), intent(in) :: val !! Input values type(array_type), pointer :: output !! Activated output values ! Local variables type(array_type), pointer :: positive_part, negative_part ! Compute SELU: λ * merge(x, α * (exp(x) - 1), x > 0) positive_part => val * this%lambda negative_part => (exp(val) - 1._real32) * this%alpha * this%lambda output => merge(positive_part, negative_part, val .gt. 0._real32) if(this%apply_scaling)then output => output * this%scale end if end function apply_selu