|
5 | 5 | use nf_dense_layer, only: dense_layer |
6 | 6 | use nf_flatten_layer, only: flatten_layer |
7 | 7 | use nf_input1d_layer, only: input1d_layer |
| 8 | + use nf_input2d_layer, only: input2d_layer |
8 | 9 | use nf_input3d_layer, only: input3d_layer |
9 | 10 | use nf_maxpool2d_layer, only: maxpool2d_layer |
10 | 11 | use nf_reshape_layer, only: reshape3d_layer |
@@ -54,6 +55,18 @@ pure module subroutine backward_1d(self, previous, gradient) |
54 | 55 | end subroutine backward_1d |
55 | 56 |
|
56 | 57 |
|
| 58 | + pure module subroutine backward_2d(self, previous, gradient) |
| 59 | + implicit none |
| 60 | + class(layer), intent(in out) :: self |
| 61 | + class(layer), intent(in) :: previous |
| 62 | + real, intent(in) :: gradient(:,:) |
| 63 | + |
| 64 | + ! Backward pass from a 2-d layer downstream currently implemented |
| 65 | + ! only for dense and flatten layers |
| 66 | + ! CURRENTLY NO LAYERS, tbd: pull/197 and pull/199 |
| 67 | + end subroutine backward_2d |
| 68 | + |
| 69 | + |
57 | 70 | pure module subroutine backward_3d(self, previous, gradient) |
58 | 71 | implicit none |
59 | 72 | class(layer), intent(in out) :: self |
@@ -224,6 +237,23 @@ pure module subroutine get_output_1d(self, output) |
224 | 237 | end subroutine get_output_1d |
225 | 238 |
|
226 | 239 |
|
| 240 | + pure module subroutine get_output_2d(self, output) |
| 241 | + implicit none |
| 242 | + class(layer), intent(in) :: self |
| 243 | + real, allocatable, intent(out) :: output(:,:) |
| 244 | + |
| 245 | + select type(this_layer => self % p) |
| 246 | + |
| 247 | + type is(input2d_layer) |
| 248 | + allocate(output, source=this_layer % output) |
| 249 | + class default |
| 250 | + error stop '1-d output can only be read from an input1d, dense, or flatten layer.' |
| 251 | + |
| 252 | + end select |
| 253 | + |
| 254 | + end subroutine get_output_2d |
| 255 | + |
| 256 | + |
227 | 257 | pure module subroutine get_output_3d(self, output) |
228 | 258 | implicit none |
229 | 259 | class(layer), intent(in) :: self |
@@ -299,6 +329,8 @@ elemental module function get_num_params(self) result(num_params) |
299 | 329 | select type (this_layer => self % p) |
300 | 330 | type is (input1d_layer) |
301 | 331 | num_params = 0 |
| 332 | + type is (input2d_layer) |
| 333 | + num_params = 0 |
302 | 334 | type is (input3d_layer) |
303 | 335 | num_params = 0 |
304 | 336 | type is (dense_layer) |
@@ -326,6 +358,8 @@ module function get_params(self) result(params) |
326 | 358 | select type (this_layer => self % p) |
327 | 359 | type is (input1d_layer) |
328 | 360 | ! No parameters to get. |
| 361 | + type is (input2d_layer) |
| 362 | + ! No parameters to get. |
329 | 363 | type is (input3d_layer) |
330 | 364 | ! No parameters to get. |
331 | 365 | type is (dense_layer) |
@@ -353,6 +387,8 @@ module function get_gradients(self) result(gradients) |
353 | 387 | select type (this_layer => self % p) |
354 | 388 | type is (input1d_layer) |
355 | 389 | ! No gradients to get. |
| 390 | + type is (input2d_layer) |
| 391 | + ! No gradients to get. |
356 | 392 | type is (input3d_layer) |
357 | 393 | ! No gradients to get. |
358 | 394 | type is (dense_layer) |
@@ -398,6 +434,11 @@ module subroutine set_params(self, params) |
398 | 434 | write(stderr, '(a)') 'Warning: calling set_params() ' & |
399 | 435 | // 'on a zero-parameter layer; nothing to do.' |
400 | 436 |
|
| 437 | + type is (input2d_layer) |
| 438 | + ! No parameters to set. |
| 439 | + write(stderr, '(a)') 'Warning: calling set_params() ' & |
| 440 | + // 'on a zero-parameter layer; nothing to do.' |
| 441 | + |
401 | 442 | type is (input3d_layer) |
402 | 443 | ! No parameters to set. |
403 | 444 | write(stderr, '(a)') 'Warning: calling set_params() ' & |
|
0 commit comments