File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,32 @@ module stdlib_specialfunctions
163
163
end interface
164
164
public :: gelu_approx_grad
165
165
166
+ interface selu
167
+ !! Version: experimental
168
+ !!
169
+ !! Scaled Exponential Linear Unit
170
+ #:for rk, rt in REAL_KINDS_TYPES
171
+ elemental module function selu_${rk}$( x ) result( y )
172
+ ${rt}$, intent(in) :: x
173
+ ${rt}$ :: y
174
+ end function
175
+ #:endfor
176
+ end interface
177
+ public :: selu
178
+
179
+ interface selu_grad
180
+ !! Version: experimental
181
+ !!
182
+ !! Scaled Exponential Linear Unit
183
+ #:for rk, rt in REAL_KINDS_TYPES
184
+ elemental module function selu_grad_${rk}$( x ) result( y )
185
+ ${rt}$, intent(in) :: x
186
+ ${rt}$ :: y
187
+ end function
188
+ #:endfor
189
+ end interface
190
+ public :: selu_grad
191
+
166
192
interface sigmoid
167
193
!! Version: experimental
168
194
!!
Original file line number Diff line number Diff line change @@ -112,6 +112,36 @@ end function
112
112
113
113
#:endfor
114
114
115
+ !==================================================
116
+ ! Scaled Exponential Linear Unit (SELU)
117
+ !==================================================
118
+ #:for rk, rt in REAL_KINDS_TYPES
119
+ elemental module function selu_${rk}$( x ) result( y )
120
+ ${rt}$, intent(in) :: x
121
+ ${rt}$ :: y
122
+ ${rt}$, parameter :: scale = 1.0507009873554804934193349852946_${rk}$
123
+ ${rt}$, parameter :: alpha = 1.6732632423543772848170429916717_${rk}$
124
+ if(x > 0._${rk}$)then
125
+ y = scale * x
126
+ else
127
+ y = scale * (alpha * exp(x) - alpha)
128
+ end if
129
+ end function
130
+
131
+ elemental module function selu_grad_${rk}$( x ) result( y )
132
+ ${rt}$, intent(in) :: x
133
+ ${rt}$ :: y
134
+ ${rt}$, parameter :: scale = 1.0507009873554804934193349852946_${rk}$
135
+ ${rt}$, parameter :: alpha = 1.6732632423543772848170429916717_${rk}$
136
+ if(x > 0._${rk}$)then
137
+ y = scale
138
+ else
139
+ y = scale * alpha * exp(x)
140
+ end if
141
+ end function
142
+
143
+ #:endfor
144
+
115
145
!==================================================
116
146
! Sigmoid
117
147
!==================================================
You can’t perform that action at this time.
0 commit comments