Apply softmax activation to 1D array
Computes: f = exp(x-max)/sum(exp(x-max))
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(softmax_actv_type), | intent(in) | :: | this |
Softmax activation type |
||
| type(array_type), | intent(in) | :: | val |
Input values |
Normalised probability distribution output
compute softmax values
function apply_softmax(this, val) result(output) !! Apply softmax activation to 1D array !! !! Computes: f = exp(x-max)/sum(exp(x-max)) implicit none ! Arguments class(softmax_actv_type), intent(in) :: this !! Softmax activation type type(array_type), intent(in) :: val !! Input values type(array_type), pointer :: output !! Normalised probability distribution output !! compute softmax values if(this%apply_scaling)then output => softmax(val, dim=2) * this%scale else output => softmax(val, dim=2) end if end function apply_softmax