GCC Code Coverage Report


Directory: src/lib/
File: src/lib/mod_activation.f90
Date: 2024-06-28 12:51:18
Exec Total Coverage
Lines: 15 16 93.8%
Functions: 0 0 -%
Branches: 38 114 33.3%

Line Branch Exec Source
1 !!!#############################################################################
2 !!! Code written by Ned Thaddeus Taylor
3 !!! Code part of the ATHENA library - a feedforward neural network library
4 !!!#############################################################################
5 !!! module to setup the activation function
6 !!! module includes the following procedures:
7 !!! - activation_setup - set up the activation function
8 !!!#############################################################################
9 module activation
10 use constants, only: real12
11 use misc, only: to_lower
12 use custom_types, only: activation_type
13 use activation_gaussian, only: gaussian_setup
14 use activation_linear, only: linear_setup
15 use activation_piecewise, only: piecewise_setup
16 use activation_relu, only: relu_setup
17 use activation_leaky_relu, only: leaky_relu_setup
18 use activation_sigmoid, only: sigmoid_setup
19 use activation_softmax, only: softmax_setup
20 use activation_tanh, only: tanh_setup
21 use activation_none, only: none_setup
22 implicit none
23
24
25 private
26
27 public :: activation_setup
28
29
30 contains
31
32 !!!#############################################################################
33 !!! function to setup the activation function
34 !!!#############################################################################
35 107 pure function activation_setup(name, scale) result(transfer)
36 implicit none
37 real(real12), optional, intent(in) :: scale
38 class(activation_type), allocatable :: transfer
39 character(*), intent(in) :: name
40
41 real(real12) :: scale_
42
43
44 !!--------------------------------------------------------------------------
45 !! set defaults if not present
46 !!--------------------------------------------------------------------------
47 107 if(present(scale))then
48 107 scale_ = scale
49 else
50 scale_ = 1._real12
51 end if
52
53
54 !!--------------------------------------------------------------------------
55 !! select desired activation function
56 !!--------------------------------------------------------------------------
57 214 select case(trim(to_lower(name)))
58 case("gaussian")
59
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4 transfer = gaussian_setup(scale = scale_)
60 case ("linear")
61
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 5 taken 9 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 9 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
9 transfer = linear_setup(scale = scale_)
62 case ("piecewise")
63
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4 transfer = piecewise_setup(scale = scale_)
64 case ("relu")
65
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4 transfer = relu_setup(scale = scale_)
66 case ("leaky_relu")
67
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4 transfer = leaky_relu_setup(scale = scale_)
68 case ("sigmoid")
69
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 16 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
16 transfer = sigmoid_setup(scale = scale_)
70 case ("softmax")
71
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4 transfer = softmax_setup(scale = scale_)
72 case ("tanh")
73
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
5 transfer = tanh_setup(scale = scale_)
74 case ("none")
75
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 5 taken 57 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 57 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
57 transfer = none_setup(scale = scale_)
76 case default
77
10/22
✓ Branch 1 taken 107 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 57 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
321 transfer = none_setup(scale = scale_)
78 end select
79
80
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
214 end function activation_setup
81 !!!#############################################################################
82
83 end module activation
84 !!!#############################################################################
85