Skip to content

Commit bccbdd4

Browse files
committed
examples
1 parent 4c1afde commit bccbdd4

File tree

8 files changed

+114
-0
lines changed

8 files changed

+114
-0
lines changed

doc/specs/stdlib_specialfunctions_activations.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ Elemental function
3333

3434
The function returns a value with the same type and kind as input argument.
3535

36+
### Example
37+
```fortran
38+
{!example/specialfunctions_activations/example_gaussian.f90!}
39+
```
40+
3641
## `Gaussian_grad` - Gradient of the Gaussian function
3742

3843
### Status
@@ -94,6 +99,11 @@ Elemental function
9499

95100
The function returns a value with the same type and kind as input argument.
96101

102+
### Example
103+
```fortran
104+
{!example/specialfunctions_activations/example_elu.f90!}
105+
```
106+
97107
## `Elu_grad` - Gradient of the Exponential Linear Unit function
98108

99109
### Status
@@ -155,6 +165,11 @@ Elemental function
155165

156166
The function returns a value with the same type and kind as input argument.
157167

168+
### Example
169+
```fortran
170+
{!example/specialfunctions_activations/example_relu.f90!}
171+
```
172+
158173
## `Relu_grad` - Gradient of the Rectified Linear Unit function
159174

160175
### Status
@@ -215,6 +230,11 @@ Elemental function
215230

216231
The function returns a value with the same type and kind as input argument.
217232

233+
### Example
234+
```fortran
235+
{!example/specialfunctions_activations/example_gelu.f90!}
236+
```
237+
218238
## `Gelu_grad` - Gradient of the Gaussian Error Linear Unit function
219239

220240
### Status
@@ -335,6 +355,11 @@ Elemental function
335355

336356
The function returns a value with the same type and kind as input argument.
337357

358+
### Example
359+
```fortran
360+
{!example/specialfunctions_activations/example_selu.f90!}
361+
```
362+
338363
## `selu_grad` - Gradient of the Scaled Exponential Linear Unit function
339364

340365
### Status
@@ -449,6 +474,11 @@ Elemental function
449474

450475
The function returns a value with the same type and kind as input argument.
451476

477+
### Example
478+
```fortran
479+
{!example/specialfunctions_activations/example_silu.f90!}
480+
```
481+
452482
## `Silu_grad` - Gradient of the Sigmoid Linear Unit function
453483

454484
### Status
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ADD_EXAMPLE(elu)
2+
ADD_EXAMPLE(gaussian)
3+
ADD_EXAMPLE(gelu)
4+
ADD_EXAMPLE(relu)
5+
ADD_EXAMPLE(selu)
6+
ADD_EXAMPLE(silu)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
program example_elu
2+
use stdlib_kinds, only: sp
3+
use stdlib_math, only: linspace
4+
use stdlib_specialfunctions, only: elu
5+
6+
integer, parameter :: n = 10
7+
real(sp) :: x(n), y(n)
8+
implicit none
9+
10+
x = linspace(-2._sp, 2._sp, n)
11+
y = elu( x , 1.0 )
12+
end program example_elu
13+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
program example_gaussian
2+
use stdlib_kinds, only: sp
3+
use stdlib_math, only: linspace
4+
use stdlib_specialfunctions, only: gaussian
5+
6+
integer, parameter :: n = 10
7+
real(sp) :: x(n), y(n)
8+
implicit none
9+
10+
x = linspace(-2._sp, 2._sp, n)
11+
y = gaussian( x )
12+
end program example_gaussian
13+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
program example_gelu
2+
use stdlib_kinds, only: sp
3+
use stdlib_math, only: linspace
4+
use stdlib_specialfunctions, only: gelu
5+
6+
integer, parameter :: n = 10
7+
real(sp) :: x(n), y(n)
8+
implicit none
9+
10+
x = linspace(-2._sp, 2._sp, n)
11+
y = gelu( x )
12+
end program example_gelu
13+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
program example_relu
2+
use stdlib_kinds, only: sp
3+
use stdlib_math, only: linspace
4+
use stdlib_specialfunctions, only: relu
5+
6+
integer, parameter :: n = 10
7+
real(sp) :: x(n), y(n)
8+
implicit none
9+
10+
x = linspace(-2._sp, 2._sp, n)
11+
y = relu( x , 1.0 )
12+
end program example_relu
13+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
program example_selu
2+
use stdlib_kinds, only: sp
3+
use stdlib_math, only: linspace
4+
use stdlib_specialfunctions, only: selu
5+
6+
integer, parameter :: n = 10
7+
real(sp) :: x(n), y(n)
8+
implicit none
9+
10+
x = linspace(-2._sp, 2._sp, n)
11+
y = selu( x )
12+
end program example_selu
13+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
program example_silu
2+
use stdlib_kinds, only: sp
3+
use stdlib_math, only: linspace
4+
use stdlib_specialfunctions, only: silu
5+
6+
integer, parameter :: n = 10
7+
real(sp) :: x(n), y(n)
8+
implicit none
9+
10+
x = linspace(-2._sp, 2._sp, n)
11+
y = silu( x )
12+
end program example_silu
13+

0 commit comments

Comments
 (0)