@@ -109,7 +109,7 @@ def load_mlp_spec(input_file):
109109 logger .info ("Loading mlp properties from %s ..." ,input_file )
110110 return load_json (input_file );
111111
112-
112+
113113#############################################################################
114114#CNN
115115#############################################################################
@@ -141,9 +141,12 @@ def initModelCNN(data):
141141def load_conv_spec (input_file ,batch_size ,input_shape ):
142142 logger .info ("Loading convnet properties from %s ..." ,input_file )
143143 data = load_json (input_file )
144-
145- layer_configs = data .pop ('layers' );
146- conv_configs = data ;
144+ if not data .has_key ('cnn' ):
145+ logger .critical ("CNN configuration is not present in " + str (input_file ))
146+ exit (1 )
147+ cnn_data = data ['cnn' ];
148+ layer_configs = cnn_data .pop ('layers' );
149+ conv_configs = cnn_data ;
147150 if len (layer_configs )== 0 :
148151 print "Error: No convnet configuration avaialable.."
149152 exit (1 )
@@ -159,7 +162,7 @@ def load_conv_spec(input_file,batch_size,input_shape):
159162
160163 current_map_number = layer_configs [layer_index ]['num_filters' ]
161164 layer_configs [layer_index ]['filter_shape' ]= [current_map_number ,prev_map_number ];
162- layer_configs [layer_index ]['filter_shape' ].extend (layer_configs [layer_index ]['convmat_dim ' ]);
165+ layer_configs [layer_index ]['filter_shape' ].extend (layer_configs [layer_index ][' ' ]);
163166
164167 layer_configs [layer_index ]['output_shape' ] = [batch_size ,current_map_number ];
165168 if not len (layer_configs [layer_index ]['input_shape' ][2 :]) == len (layer_configs [layer_index ]['convmat_dim' ]):
@@ -172,7 +175,11 @@ def load_conv_spec(input_file,batch_size,input_shape):
172175 input_shape .append (outdim );
173176
174177 prev_map_number = current_map_number
175- return (conv_configs ,layer_configs )
178+ if not data .has_key ('cnn' ):
179+ logger .critical ("mlp configuration is not present in " + str (input_file ))
180+ exit (1 )
181+ mlp_configs = data ['mlp' ];
182+ return (conv_configs ,layer_configs ,mlp_configs )
176183
177184#############################################################################
178185#DBN/RBM
0 commit comments