This is an automated email from the ASF dual-hosted git repository.

domino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/madlib.git

commit dbae72239ed3d201bf675e7aafd6f44903f6f007
Author: Ekta Khanna <ekha...@pivotal.io>
AuthorDate: Mon Jan 13 15:48:11 2020 -0800

    DL: Fix metrics_elapsed_time for fit multi model
    
    JIRA: MADLIB-1403
    
    Prior to this commit, for madlib_keras_fit_multiple_model(), the
    metrics_elapsed_time in info table was incorrectly stored as the per
    iteration evaluation time instead of the elapsed time. This commit
    fixes that issue and adds an assert for it too.
    
    Co-authored-by: Nikhil Kak <n...@pivotal.io>
---
 .../modules/deep_learning/madlib_keras_fit_multiple_model.py_in      | 5 +++--
 .../modules/deep_learning/test/madlib_keras_model_selection.sql_in   | 4 ++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git 
a/src/ports/postgres/modules/deep_learning/madlib_keras_fit_multiple_model.py_in
 
b/src/ports/postgres/modules/deep_learning/madlib_keras_fit_multiple_model.py_in
index 273321e..ae577e8 100644
--- 
a/src/ports/postgres/modules/deep_learning/madlib_keras_fit_multiple_model.py_in
+++ 
b/src/ports/postgres/modules/deep_learning/madlib_keras_fit_multiple_model.py_in
@@ -172,6 +172,7 @@ class FitMultipleModel():
         # WARNING: set orca off to prevent unwanted redistribution
         with OptimizerControl(False):
             self.start_training_time = datetime.datetime.now()
+            self.metrics_elapsed_start_time = time.time()
             self.train_multiple_model()
             self.end_training_time = datetime.datetime.now()
             self.insert_info_table()
@@ -219,7 +220,7 @@ class FitMultipleModel():
             weights = query_weights(self.model_output_table, 
self.model_weights_col,
                 self.mst_key_col, mst[self.mst_key_col])
             model_arch, _ = get_model_arch_weights(self.model_arch_table, 
mst[self.model_id_col])
-            metric_eval_time, metric, loss = compute_loss_and_metrics(
+            _, metric, loss = compute_loss_and_metrics(
                 self.schema_madlib, table, "$madlib${0}$madlib$".format(
                     mst[self.compile_params_col]),
                 model_arch,
@@ -230,7 +231,7 @@ class FitMultipleModel():
                 images_per_seg,
                 [], [], epoch, True)
             mst_metric_eval_time[mst[self.mst_key_col]] \
-                .append(metric_eval_time)
+                .append(time.time() - self.metrics_elapsed_start_time)
             mst_loss[mst[self.mst_key_col]].append(loss)
             mst_metric[mst[self.mst_key_col]].append(metric)
             self.info_str += "\n\tmst_key={0}: metric={1}, 
loss={2}".format(mst[self.mst_key_col], metric, loss)
diff --git 
a/src/ports/postgres/modules/deep_learning/test/madlib_keras_model_selection.sql_in
 
b/src/ports/postgres/modules/deep_learning/test/madlib_keras_model_selection.sql_in
index c36d48f..26c1a34 100644
--- 
a/src/ports/postgres/modules/deep_learning/test/madlib_keras_model_selection.sql_in
+++ 
b/src/ports/postgres/modules/deep_learning/test/madlib_keras_model_selection.sql_in
@@ -320,6 +320,10 @@ SELECT assert(
         'Keras Fit Multiple Output Info Validation failed. Actual:' || 
__to_char(info))
 FROM (SELECT * FROM iris_multiple_model_info) info;
 
+SELECT assert(metrics_elapsed_time[3] - metrics_elapsed_time[1] > 0,
+        'Keras Fit Multiple invalid elapsed time calculation.')
+FROM (SELECT * FROM iris_multiple_model_info) info;
+
 SELECT assert(
         name = 'multi_model_name' AND
         description = 'multi_model_descr' AND

Reply via email to