Skip to content

Commit f22756a

Browse files
committed
fix float constant definition
1 parent c1303e7 commit f22756a

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/stdlib_specialfunctions_activations.fypp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ submodule(stdlib_specialfunctions) stdlib_specialfunctions_activations
33
implicit none
44

55
#:for rk, rt in REAL_KINDS_TYPES
6-
${rt}$, parameter :: isqrt2_${rk}$ = 1_${rk}$ / sqrt(2._${rk}$)
6+
${rt}$, parameter :: isqrt2_${rk}$ = 1._${rk}$ / sqrt(2._${rk}$)
77
#:endfor
88

99
contains
@@ -37,7 +37,7 @@ elemental ${rt}$ module function elu_${rk}$( x , a ) result ( y )
3737
if(x >= 0._${rk}$)then
3838
y = x
3939
else
40-
y = a * (exp(x) - 1_${rk}$)
40+
y = a * (exp(x) - 1._${rk}$)
4141
end if
4242
end function
4343

@@ -46,7 +46,7 @@ elemental ${rt}$ module function elu_grad_${rk}$( x , a ) result ( y )
4646
${rt}$, intent(in) :: a
4747

4848
if(x >= 0._${rk}$)then
49-
y = 1_${rk}$
49+
y = 1._${rk}$
5050
else
5151
y = a * exp(x)
5252
end if
@@ -68,7 +68,7 @@ elemental ${rt}$ module function relu_grad_${rk}$( x ) result( y )
6868
${rt}$, intent(in) :: x
6969

7070
if(x > 0._${rk}$)then
71-
y = 1_${rk}$
71+
y = 1._${rk}$
7272
else
7373
y = 0._${rk}$
7474
end if
@@ -118,13 +118,13 @@ end function
118118
elemental ${rt}$ module function sigmoid_${rk}$( x ) result( y )
119119
${rt}$, intent(in) :: x
120120

121-
y = 1_${rk}$ / (1_${rk}$ + exp(-x))
121+
y = 1._${rk}$ / (1._${rk}$ + exp(-x))
122122
end function
123123

124124
elemental ${rt}$ module function sigmoid_grad_${rk}$( x ) result( y )
125125
${rt}$, intent(in) :: x
126126

127-
y = exp(x) / (1_${rk}$ + exp(x))**2
127+
y = exp(x) / (1._${rk}$ + exp(x))**2
128128
end function
129129

130130
#:endfor
@@ -137,7 +137,7 @@ elemental ${rt}$ module function Step_${rk}$( x ) result( y )
137137
${rt}$, intent(in) :: x
138138

139139
if(x > 0._${rk}$)then
140-
y = 1_${rk}$
140+
y = 1._${rk}$
141141
else
142142
y = 0._${rk}$
143143
end if
@@ -164,7 +164,7 @@ end function
164164
elemental ${rt}$ module function tanh_grad_${rk}$( x ) result( y )
165165
${rt}$, intent(in) :: x
166166

167-
y = 1_${rk}$ - ftanh(x)**2
167+
y = 1._${rk}$ - ftanh(x)**2
168168
end function
169169

170170
#:endfor
@@ -246,7 +246,7 @@ pure function Softmax_grad_r1_${rk}$( x ) result( y )
246246
${rt}$ :: y(size(x))
247247

248248
y = Softmax(x)
249-
y = y * (1_${rk}$ - y)
249+
y = y * (1._${rk}$ - y)
250250
end function
251251

252252
pure function Softmax_grad_r2_${rk}$( x , dim ) result( y )
@@ -259,7 +259,7 @@ pure function Softmax_grad_r2_${rk}$( x , dim ) result( y )
259259
dim_ = 1; if(present(dim)) dim_ = dim
260260

261261
y = Softmax(x,dim_)
262-
y = y * (1_${rk}$ - y)
262+
y = y * (1._${rk}$ - y)
263263
end function
264264

265265
pure function Softmax_grad_r3_${rk}$( x , dim ) result( y )
@@ -272,7 +272,7 @@ pure function Softmax_grad_r3_${rk}$( x , dim ) result( y )
272272
dim_ = 1; if(present(dim)) dim_ = dim
273273

274274
y = Softmax(x,dim_)
275-
y = y * (1_${rk}$ - y)
275+
y = y * (1._${rk}$ - y)
276276
end function
277277

278278
pure function Softmax_grad_r4_${rk}$( x , dim ) result( y )
@@ -285,7 +285,7 @@ pure function Softmax_grad_r4_${rk}$( x , dim ) result( y )
285285
dim_ = 1; if(present(dim)) dim_ = dim
286286

287287
y = Softmax(x,dim_)
288-
y = y * (1_${rk}$ - y)
288+
y = y * (1._${rk}$ - y)
289289
end function
290290

291291
#:endfor
@@ -297,13 +297,13 @@ end function
297297
elemental ${rt}$ module function Softplus_${rk}$( x ) result( y )
298298
${rt}$, intent(in) :: x
299299

300-
y = log(exp(x) + 1_${rk}$)
300+
y = log(exp(x) + 1._${rk}$)
301301
end function
302302

303303
elemental ${rt}$ module function Softplus_grad_${rk}$( x ) result( y )
304304
${rt}$, intent(in) :: x
305305

306-
y = exp(x) / (exp(x) + 1_${rk}$)
306+
y = exp(x) / (exp(x) + 1._${rk}$)
307307
end function
308308

309309
#:endfor
@@ -318,9 +318,9 @@ elemental ${rt}$ module function ftanh_${rk}$( x ) result( y )
318318
${rt}$ :: x2, a, b
319319

320320
if (x > 5_${rk}$) then
321-
y = 1_${rk}$
321+
y = 1._${rk}$
322322
elseif (x < -5_${rk}$) then
323-
y = -1_${rk}$
323+
y = -1._${rk}$
324324
else
325325
x2 = x*x
326326
a = x * (135135.0_${rk}$ + x2 * (17325.0_${rk}$ + x2 * (378.0_${rk}$ + x2)))
@@ -334,7 +334,7 @@ elemental ${rt}$ module function ferf_${rk}$( x ) result( y )
334334
${rt}$ :: abs_x
335335

336336
abs_x = abs(x)
337-
y = 1_${rk}$ - 1_${rk}$ / (1+ 0.278393_${rk}$*abs_x + 0.230389_${rk}$*abs_x**2 + 0.000972_${rk}$*abs_x**3 + 0.078108_${rk}$*abs_x**4)**4
337+
y = 1._${rk}$ - 1._${rk}$ / (1+ 0.278393_${rk}$*abs_x + 0.230389_${rk}$*abs_x**2 + 0.000972_${rk}$*abs_x**3 + 0.078108_${rk}$*abs_x**4)**4
338338
y = y * sign(1.0_${rk}$,x)
339339
end function
340340

0 commit comments

Comments
 (0)