njayaram2 commented on a change in pull request #395: DL: 
madlib_keras_evaluate() function
URL: https://github.com/apache/madlib/pull/395#discussion_r286623996
 
 

 ##########
 File path: src/ports/postgres/modules/deep_learning/madlib_keras.py_in
 ##########
 @@ -551,43 +544,51 @@ def fit_final(state, **kwargs):
     return madlib_keras_serializer.serialize_weights_merge(
         loss, accuracy, image_count, weights)
 
-def evaluate1(schema_madlib, model_table, test_table, id_col, model_arch_table,
-            model_arch_id, dependent_varname, independent_varname,
-            compile_params, output_table, **kwargs):
-    # module_name = 'madlib_keras_evaluate'
-    # input_tbl_valid(test_table, module_name)
-    # input_tbl_valid(model_arch_table, module_name)
-    # output_tbl_valid(output_table, module_name)
+def evaluate(schema_madlib, model_table, test_table, dependent_varname, 
independent_varname,
+             output_table, gpus_per_host, **kwargs):
+    module_name = 'madlib_keras_evaluate'
+    input_validator = EvaluateInputValidator(test_table, model_table, 
independent_varname,
+                                             output_table, module_name)
 
-    # _validate_input_args(test_table, model_arch_table, output_table)
+    model_summary_table = input_validator.model_summary_table
 
-    model_data_query = "SELECT model_data from {0}".format(model_table)
-    model_data = plpy.execute(model_data_query)[0]['model_data']
+    gpus_per_host = 0 if gpus_per_host is None else gpus_per_host
+    segments_per_host = get_segments_per_host()
 
-    model_arch_query = "SELECT model_arch, model_weights FROM {0} " \
-                       "WHERE id = {1}".format(model_arch_table, model_arch_id)
-    query_result = plpy.execute(model_arch_query)
-    if not  query_result or len(query_result) == 0:
-        plpy.error("no model arch found in table {0} with id {1}".format(
-            model_arch_table, model_arch_id))
-    query_result = query_result[0]
-    model_arch = query_result[Format.MODEL_ARCH]
+    if 0 < gpus_per_host < segments_per_host:
+        plpy.warning('The number of gpus per host is less than the number of '
+                     'segments per host. The support for this case is '
+                     'experimental and it may fail.')
+
+    model_data_query = "SELECT model_data, model_arch from 
{0}".format(model_table)
+    res = plpy.execute(model_data_query)[0]
+    model_data = res['model_data']
+    model_arch = res['model_arch']
+
+    compile_params_query = "SELECT compile_params FROM 
{0}".format(model_summary_table)
+    compile_params = plpy.execute(compile_params_query)[0]['compile_params']
     compile_params = "$madlib$" + compile_params + "$madlib$"
 
-    loss_acc = get_loss_acc_from_keras_eval(schema_madlib, test_table, 
dependent_varname,
+    seg_ids, images_per_seg = get_images_per_seg(test_table, dependent_varname)
+
+
+    loss, metric = get_loss_metric_from_keras_eval(schema_madlib, test_table, 
dependent_varname,
                                             independent_varname, 
compile_params, model_arch,
-                                            model_data, False, None)
+                                            model_data, gpus_per_host, 
segments_per_host, seg_ids,
+                                            images_per_seg)
 
 Review comment:
   Please fix the indentation and limit chars per line to 80, here in other 
places applicable.

----------------------------------------------------------------
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