kaknikhil commented on a change in pull request #372: DL: Trap unsupported 
options for compile and fit params
URL: https://github.com/apache/madlib/pull/372#discussion_r278780534
 
 

 ##########
 File path: src/ports/postgres/modules/deep_learning/madlib_keras_wrapper.py_in
 ##########
 @@ -120,9 +121,14 @@ def parse_compile_params(str_of_args):
 
     opt_name,opt_args = parse_optimizer(compile_dict)
     compile_dict['loss'] = parse_loss(compile_dict)
+    accepted_compile_params = ['metrics', 'loss_weights', 'weighted_metrics', 
'sample_weight_mode']
 
-    compile_dict['metrics'] = ast.literal_eval(compile_dict['metrics']) if 
'metrics' in compile_dict.keys() else None
-    compile_dict['loss_weights'] = 
ast.literal_eval(compile_dict['loss_weights']) if 'loss_weights' in 
compile_dict.keys() else None
+    for key in accepted_compile_params:
+        try:
+            compile_dict[key] = ast.literal_eval(compile_dict[key]) if key in 
compile_dict.keys() else None
+        except ValueError:
 
 Review comment:
   Few observations
   1. I noticed that we are asserting for the key to exist in the compile_dict 
in a diff function. This is a bit confusing.
   3. We should try to have consistent function interfaces(at least similar 
names) for validating and parsing the fit and compile params. There is some 
code to be reused since both of them assert that the key is not in the dict and 
then run `ast.literal_eval`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to