njayaram2 commented on a change in pull request #430: Add generate mst table 
utility.
URL: https://github.com/apache/madlib/pull/430#discussion_r312197149
 
 

 ##########
 File path: 
src/ports/postgres/modules/deep_learning/madlib_keras_model_hopper_utilities.py_in
 ##########
 @@ -0,0 +1,147 @@
+"""Summary
+"""
+# coding=utf-8
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+
+import plpy
+from collections import OrderedDict
+from madlib_keras_validator import GenerateMstInputValidator
+from utilities.control import MinWarning
+
+
+@MinWarning("warning")
+class GenerateMstTable():
+
+    """The utility class for generating mst table from the input parameters.
+
+    Currently just takes the combinations of the input parameters. This
+    utility validates the inputs.
+
+    Attributes:
+        compile_params_list (list): The input list of compile params choices.
+        fit_params_list (list): The input list of fit params choices.
+        model_arch_id_list (list): The input list of model id choices.
+        model_arch_table (str): The name of model architechure table.
+        model_selection_table (str): The name of the output mst table.
+        msts (list): The list of generated msts.
+
+    """
+
+    def __init__(self,
+                 model_selection_table,
+                 model_arch_table,
+                 model_arch_id_list,
+                 compile_params_list,
+                 fit_params_list,
+                 **kwargs):
+
+        self.model_arch_table = model_arch_table
+        self.model_selection_table = model_selection_table
+        self.model_arch_id_list = sorted(list(set(model_arch_id_list)))
+        self.compile_params_list = self.params_preprocessed(
+            compile_params_list)
+        self.fit_params_list = self.params_preprocessed(fit_params_list)
+
+        GenerateMstInputValidator(
+            model_selection_table=self.model_selection_table,
+            model_arch_table=self.model_arch_table,
+            model_arch_id_list=self.model_arch_id_list,
+            compile_params_list=self.compile_params_list,
+            fit_params_list=self.fit_params_list
+        )
+        self.msts = []
+
+        self.find_combinations()
+
+    def generate(self):
+        """The entry point for generating the mst table.
+        """
+        # All of the side effects happen in this function.
+        self.create_mst_table()
+        self.insert_into_mst_table()
+
+    def params_preprocessed(self, list_strs):
+        """Preprocess the input lists. Eliminate white spaces and sort them.
+
+        Args:
+            list_strs (list): A list of strings.
+
+        Returns:
+            list: The preprocessed list of strings.
+        """
+        res = [x.replace(' ', '') for x in list_strs]
+        res = sorted(list(set(res)))
+        return res
 
 Review comment:
   It doesn't look like this can deduplicate the following right:
   ```
   ARRAY[
           $$epochs=1, batch_size=5$$,
           $$batch_size=5,epochs=1$$
       ]
   ```
   Similar example applicable to compile params as well (I presume Keras is 
fine if we swap these orders).

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