88contains
99
1010 module function locally_connected2d_layer_cons (filters , kernel_size , activation ) result(res)
11- implicit none
1211 integer , intent (in ) :: filters
1312 integer , intent (in ) :: kernel_size
1413 class(activation_function), intent (in ) :: activation
@@ -21,7 +20,6 @@ module function locally_connected2d_layer_cons(filters, kernel_size, activation)
2120 end function locally_connected2d_layer_cons
2221
2322 module subroutine init (self , input_shape )
24- implicit none
2523 class(locally_connected2d_layer), intent (in out ) :: self
2624 integer , intent (in ) :: input_shape(:)
2725
@@ -52,16 +50,11 @@ module subroutine init(self, input_shape)
5250 end subroutine init
5351
5452 pure module subroutine forward(self, input)
55- implicit none
5653 class(locally_connected2d_layer), intent (in out ) :: self
5754 real , intent (in ) :: input(:,:)
58- integer :: input_channels, input_width
5955 integer :: j, n
6056 integer :: iws, iwe
6157
62- input_channels = size (input, dim= 1 )
63- input_width = size (input, dim= 2 )
64-
6558 do j = 1 , self % width
6659 iws = j
6760 iwe = j + self % kernel_size - 1
@@ -73,27 +66,21 @@ pure module subroutine forward(self, input)
7366 end subroutine forward
7467
7568 pure module subroutine backward(self, input, gradient)
76- implicit none
7769 class(locally_connected2d_layer), intent (in out ) :: self
7870 real , intent (in ) :: input(:,:)
7971 real , intent (in ) :: gradient(:,:)
80- integer :: input_channels, input_width, output_width
8172 integer :: j, n, k
8273 integer :: iws, iwe
8374 real :: gdz(self % filters, self % width)
8475 real :: db_local(self % filters, self % width)
8576 real :: dw_local(self % filters, self % width, self % channels, self % kernel_size)
8677
87- input_channels = size (input, dim= 1 )
88- input_width = size (input, dim= 2 )
89- output_width = self % width
90-
91- do j = 1 , output_width
78+ do j = 1 , self % width
9279 gdz(:, j) = gradient(:, j) * self % activation % eval_prime(self % z(:, j))
9380 end do
9481
9582 do n = 1 , self % filters
96- do j = 1 , output_width
83+ do j = 1 , self % width
9784 db_local(n, j) = gdz(n, j)
9885 end do
9986 end do
@@ -102,7 +89,7 @@ pure module subroutine backward(self, input, gradient)
10289 self % gradient = 0.0
10390
10491 do n = 1 , self % filters
105- do j = 1 , output_width
92+ do j = 1 , self % width
10693 iws = j
10794 iwe = j + self % kernel_size - 1
10895 do k = 1 , self % channels
0 commit comments