@@ -39,30 +39,31 @@ module function get_keras_h5_layers(filename) result(res)
3939 call json % get_child(layers_json, n, layer_json)
4040
4141 ! Get type of layer as a string
42- call json % get(layer_json, ' class_name' , res(n) % type )
42+ call json % get(layer_json, ' class_name' , res(n) % class )
4343
4444 ! Get pointer to the layer config
4545 call json % get(layer_json, ' config' , layer_config_json)
4646
47+ ! Get layer name
48+ call json % get(layer_config_json, ' name' , res(n) % name)
49+
4750 ! Get size of layer and activation if applicable;
4851 ! Instantiate neural-fortran layers at this time.
49- if (res(n) % type == ' InputLayer' ) then
50-
51- call json % get(layer_config_json, ' batch_input_shape' , tmp_array)
52- res(n) % num_elements = [tmp_array(2 )]
53-
54- else if (res(n) % type == ' Dense' ) then
55-
56- call json % get(layer_config_json, ' units' , num_elements, found)
57- res(n) % num_elements = [num_elements]
52+ select case (res(n) % class)
5853
59- call json % get(layer_config_json, ' activation' , res(n) % activation)
54+ case (' InputLayer' )
55+ call json % get(layer_config_json, ' batch_input_shape' , tmp_array)
56+ res(n) % num_elements = [tmp_array(2 )]
6057
61- else
62-
63- error stop ' This layer is not supported'
58+ case (' Dense' )
59+ call json % get(layer_config_json, ' units' , num_elements, found)
60+ res(n) % num_elements = [num_elements]
61+ call json % get(layer_config_json, ' activation' , res(n) % activation)
6462
65- end if
63+ case default
64+ error stop ' This Keras layer is not supported'
65+
66+ end select
6667
6768 end do layers
6869
0 commit comments