11program test_dense_layer
2+ use iso_fortran_env, only: stderr = > error_unit
23 use nf, only: dense, layer
34 implicit none
45 type (layer) :: layer1, layer2
@@ -8,44 +9,49 @@ program test_dense_layer
89
910 if (.not. layer1 % name == ' dense' ) then
1011 ok = .false.
11- print ' (a)' , ' dense layer has its name set correctly.. failed'
12+ write (stderr, ' (a)' ) ' dense layer has its name set correctly.. failed'
1213 end if
1314
1415 if (.not. all (layer1 % layer_shape == [10 ])) then
1516 ok = .false.
16- print ' (a)' , ' dense layer is created with requested size.. failed'
17+ write (stderr, ' (a)' ) ' dense layer is created with requested size.. failed'
1718 end if
1819
1920 if (layer1 % initialized) then
2021 ok = .false.
21- print ' (a)' , ' dense layer should not be marked as initialized yet.. failed'
22+ write (stderr, ' (a)' ) ' dense layer should not be marked as initialized yet.. failed'
2223 end if
2324
2425 if (.not. layer1 % activation == ' sigmoid' ) then
2526 ok = .false.
26- print ' (a)' , ' dense layer is defaults to sigmoid activation.. failed'
27+ write (stderr, ' (a)' ) ' dense layer is defaults to sigmoid activation.. failed'
2728 end if
2829
2930 layer1 = dense(10 , activation= ' relu' )
3031
3132 if (.not. layer1 % activation == ' relu' ) then
3233 ok = .false.
33- print ' (a)' , ' dense layer is created with the specified activation.. failed'
34+ write (stderr, ' (a)' ) ' dense layer is created with the specified activation.. failed'
3435 end if
3536
3637 layer2 = dense(20 )
3738 call layer2 % init(layer1)
3839
3940 if (.not. layer2 % initialized) then
4041 ok = .false.
41- print ' (a)' , ' dense layer should now be marked as initialized.. failed'
42+ write (stderr, ' (a)' ) ' dense layer should now be marked as initialized.. failed'
4243 end if
4344
4445 if (.not. all (layer2 % input_layer_shape == [10 ])) then
4546 ok = .false.
46- print ' (a)' , ' dense layer should have a correct input layer shape.. failed'
47+ write (stderr, ' (a)' ) ' dense layer should have a correct input layer shape.. failed'
4748 end if
4849
49- if (ok) print ' (a)' , ' test_dense_layer: All tests passed.'
50+ if (ok) then
51+ print ' (a)' , ' test_dense_layer: All tests passed.'
52+ else
53+ write (stderr, ' (a)' ) ' test_dense_layer: One or more tests failed.'
54+ stop 1
55+ end if
5056
5157end program test_dense_layer
0 commit comments