11program test_keras_read_model
22
33 use iso_fortran_env, only: stderr = > error_unit
4- use nf_datasets, only: download_and_unpack, keras_model_dense_mnist_url
4+ use nf_datasets, only: download_and_unpack, keras_dense_mnist_url, &
5+ keras_cnn_mnist_url
56 use nf_keras, only: get_keras_h5_layers, keras_layer
67 use nf, only: layer, network, dense, input
78
89 implicit none
910
1011 character (:), allocatable :: model_config_string
11- character (* ), parameter :: test_data_path = ' keras_dense_mnist.h5'
12+ character (* ), parameter :: keras_dense_path = ' keras_dense_mnist.h5'
13+ character (* ), parameter :: keras_cnn_path = ' keras_cnn_mnist.h5'
1214
1315 type (keras_layer), allocatable :: keras_layers(:)
1416
@@ -19,10 +21,12 @@ program test_keras_read_model
1921 logical :: file_exists
2022 logical :: ok = .true.
2123
22- inquire (file= test_data_path, exist= file_exists)
23- if (.not. file_exists) call download_and_unpack(keras_model_dense_mnist_url)
24+ ! First test the dense model
2425
25- keras_layers = get_keras_h5_layers(test_data_path)
26+ inquire (file= keras_dense_path, exist= file_exists)
27+ if (.not. file_exists) call download_and_unpack(keras_dense_mnist_url)
28+
29+ keras_layers = get_keras_h5_layers(keras_dense_path)
2630
2731 if (size (keras_layers) /= 3 ) then
2832 ok = .false.
@@ -51,6 +55,13 @@ program test_keras_read_model
5155 ' Keras second and third layers should be dense.. failed'
5256 end if
5357
58+ ! Now testing for the CNN model
59+
60+ inquire (file= keras_cnn_path, exist= file_exists)
61+ if (.not. file_exists) call download_and_unpack(keras_cnn_mnist_url)
62+
63+ keras_layers = get_keras_h5_layers(keras_cnn_path)
64+
5465 if (ok) then
5566 print ' (a)' , ' test_keras_read_model: All tests passed.'
5667 else
0 commit comments