Skip to content

Commit 5acdc52

Browse files
committed
Update test programs
1 parent 908f76b commit 5acdc52

File tree

6 files changed

+102
-128
lines changed

6 files changed

+102
-128
lines changed

test/test_dense_layer.f90

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
program test_dense_layer
2+
use nf, only: dense, layer
3+
implicit none
4+
type(layer) :: layer1, layer2
5+
logical :: ok = .true.
6+
7+
layer1 = dense(10)
8+
9+
if (.not. layer1 % name == 'dense') then
10+
ok = .false.
11+
print '(a)', 'dense layer has its name set correctly.. failed'
12+
end if
13+
14+
if (.not. all(layer1 % layer_shape == [10])) then
15+
ok = .false.
16+
print '(a)', 'dense layer is created with requested size.. failed'
17+
end if
18+
19+
if (layer1 % initialized) then
20+
ok = .false.
21+
print '(a)', 'dense layer should not be marked as initialized yet.. failed'
22+
end if
23+
24+
if (.not. layer1 % activation == 'sigmoid') then
25+
ok = .false.
26+
print '(a)', 'dense layer is defaults to sigmoid activation.. failed'
27+
end if
28+
29+
layer1 = dense(10, activation='relu')
30+
31+
if (.not. layer1 % activation == 'relu') then
32+
ok = .false.
33+
print '(a)', 'dense layer is created with the specified activation.. failed'
34+
end if
35+
36+
layer2 = dense(20)
37+
call layer2 % init(layer1)
38+
39+
if (.not. layer2 % initialized) then
40+
ok = .false.
41+
print '(a)', 'dense layer should now be marked as initialized.. failed'
42+
end if
43+
44+
if (.not. all(layer2 % input_layer_shape == [10])) then
45+
ok = .false.
46+
print '(a)', 'dense layer should have a correct input layer shape.. failed'
47+
end if
48+
49+
if (ok) print '(a)', 'test_dense_layer: All tests passed.'
50+
51+
end program test_dense_layer

test/test_input1d_layer.f90

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
program test_input1d_layer
2+
use nf, only: input, layer
3+
use nf_input1d_layer, only: input1d_layer
4+
implicit none
5+
type(layer) :: test_layer
6+
real, allocatable :: output(:)
7+
logical :: ok = .true.
8+
9+
test_layer = input(3)
10+
11+
if (.not. test_layer % name == 'input') then
12+
ok = .false.
13+
print '(a)', 'input1d layer has its name set correctly.. failed'
14+
end if
15+
16+
if (.not. test_layer % initialized) then
17+
ok = .false.
18+
print '(a)', 'input1d layer should be marked as initialized.. failed'
19+
end if
20+
21+
if (.not. all(test_layer % layer_shape == [3])) then
22+
ok = .false.
23+
print '(a)', 'input1d layer is created with requested size.. failed'
24+
end if
25+
26+
if (.not. size(test_layer % input_layer_shape) == 0) then
27+
ok = .false.
28+
print '(a)', 'input1d layer has no input layer shape.. failed'
29+
end if
30+
31+
call test_layer % get_output(output)
32+
33+
if (.not. all(output == 0)) then
34+
ok = .false.
35+
print '(a)', 'input1d layer values are all initialized to 0.. failed'
36+
end if
37+
38+
select type(input_layer => test_layer % p); type is(input1d_layer)
39+
call input_layer % set([1., 2., 3.])
40+
end select
41+
42+
call test_layer % get_output(output)
43+
44+
if (.not. all(output == [1., 2., 3.])) then
45+
ok = .false.
46+
print '(a)', 'input1d layer can have its values set.. failed'
47+
end if
48+
49+
if (ok) print '(a)', 'test_input1d_layer: All tests passed.'
50+
51+
end program test_input1d_layer

test/test_mnist.f90

Lines changed: 0 additions & 24 deletions
This file was deleted.

test/test_network_save.f90

Lines changed: 0 additions & 32 deletions
This file was deleted.

test/test_network_sync.f90

Lines changed: 0 additions & 9 deletions
This file was deleted.

test/test_set_activation_function.f90

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)