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 contains the container layer type for handling interactions ... |
6 |
|
|
!!! ... between individual layers |
7 |
|
|
!!!################## |
8 |
|
|
!!! module contains the following derived types: |
9 |
|
|
!!! - container_layer_type - type for handling interactions between layers |
10 |
|
|
!!!################## |
11 |
|
|
!!! module contains the following procedures: |
12 |
|
|
!!! - forward - forward pass |
13 |
|
|
!!! - backward - backward pass |
14 |
|
|
!!! - container_reduction - reduction of container layers |
15 |
|
|
!!!############################################################################# |
16 |
|
|
module container_layer |
17 |
|
|
use constants, only: real12 |
18 |
|
|
use base_layer, only: base_layer_type |
19 |
|
|
implicit none |
20 |
|
|
|
21 |
|
|
|
22 |
|
|
!!!------------------------------------------------------------------------ |
23 |
|
|
!!! layer container type |
24 |
|
|
!!!------------------------------------------------------------------------ |
25 |
|
|
type :: container_layer_type |
26 |
|
|
!! inpt, batc, conv, drop, full, pool, flat |
27 |
|
|
character(4) :: name |
28 |
|
|
class(base_layer_type), allocatable :: layer |
29 |
|
|
contains |
30 |
|
|
procedure, pass(this) :: forward |
31 |
|
|
procedure, pass(this) :: backward |
32 |
|
|
|
33 |
|
|
#if defined(GFORTRAN) |
34 |
|
|
procedure, pass(this) :: reduce => container_reduction |
35 |
|
|
#endif |
36 |
|
|
end type container_layer_type |
37 |
|
|
|
38 |
|
|
|
39 |
|
|
interface |
40 |
|
|
!!----------------------------------------------------- |
41 |
|
|
!! forward pass |
42 |
|
|
!!----------------------------------------------------- |
43 |
|
|
!! this = (T, io) present layer container |
44 |
|
|
!! input = (T, in) input layer container |
45 |
|
|
pure module subroutine forward(this, input) |
46 |
|
|
!import container_layer_type |
47 |
|
|
class(container_layer_type), intent(inout) :: this |
48 |
|
|
class(container_layer_type), intent(in) :: input |
49 |
|
|
end subroutine forward |
50 |
|
|
end interface |
51 |
|
|
|
52 |
|
|
interface |
53 |
|
|
!!----------------------------------------------------- |
54 |
|
|
!! forward pass |
55 |
|
|
!!----------------------------------------------------- |
56 |
|
|
!! this = (T, in) present layer container |
57 |
|
|
!! input = (T, in) input layer container |
58 |
|
|
!! gradient = (R, in) backpropagated gradient |
59 |
|
|
pure module subroutine backward(this, input, gradient) |
60 |
|
|
!import container_layer_type, real12 |
61 |
|
|
class(container_layer_type), intent(inout) :: this |
62 |
|
|
class(container_layer_type), intent(in) :: input |
63 |
|
|
real(real12), dimension(..), intent(in) :: gradient |
64 |
|
|
end subroutine backward |
65 |
|
|
end interface |
66 |
|
|
|
67 |
|
|
#if defined(GFORTRAN) |
68 |
|
|
interface |
69 |
|
|
!!----------------------------------------------------- |
70 |
|
|
!! forward pass |
71 |
|
|
!!----------------------------------------------------- |
72 |
|
|
!! this = (T, io) present layer container |
73 |
|
|
!! rhs = (T, in) input layer container |
74 |
|
|
module subroutine container_reduction(this, rhs) |
75 |
|
|
!import container_layer_type, real12 |
76 |
|
|
class(container_layer_type), intent(inout) :: this |
77 |
|
|
class(container_layer_type), intent(in) :: rhs |
78 |
|
|
end subroutine |
79 |
|
|
end interface |
80 |
|
|
#endif |
81 |
|
|
|
82 |
|
|
|
83 |
|
|
private |
84 |
|
|
public :: container_layer_type |
85 |
|
|
#if defined(GFORTRAN) |
86 |
|
|
public :: container_reduction |
87 |
|
|
#endif |
88 |
|
|
|
89 |
|
|
|
90 |
|
✗ |
end module container_layer |
91 |
|
|
!!!############################################################################# |
92 |
|
|
|