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

 ##########
 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.')
 
 Review comment:
   The same if check is in `fit` function as well. We should refactor the 
following snippet to a different function (may be named 
`validate_and_get_gpus_per_host`?):
   ```
   gpus_per_host = 0 if gpus_per_host is None else gpus_per_host
   segments_per_host = get_segments_per_host()
   
   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.')
   ```

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