kaknikhil commented on a change in pull request #360: Deep Learning: Add 
support for one-hot encoded dep var
URL: https://github.com/apache/madlib/pull/360#discussion_r270604360
 
 

 ##########
 File path: src/ports/postgres/modules/deep_learning/madlib_keras_helper.py_in
 ##########
 @@ -174,21 +182,129 @@ def get_data_as_np_array(table_name, y, x, input_shape, 
num_classes):
     indep_len = len(val_data[0][x])
     pixels_per_image = int(input_shape[0] * input_shape[1] * input_shape[2])
     x_validation = np.ndarray((0,indep_len, pixels_per_image))
-    y_validation = np.ndarray((0,indep_len))
+    y_validation = np.ndarray((0,indep_len, num_classes))
     for i in range(len(val_data)):
         x_test = np.asarray((val_data[i][x],))
         x_test = x_test.reshape(1, indep_len, pixels_per_image)
         y_test = np.asarray((val_data[i][y],))
-        y_test = y_test.reshape(1, indep_len)
         x_validation=np.concatenate((x_validation, x_test))
         y_validation=np.concatenate((y_validation, y_test))
     num_test_examples = x_validation.shape[0]
     x_validation = x_validation.reshape(indep_len * num_test_examples, 
*input_shape)
     x_validation = x_validation.astype('float64')
-    y_validation = y_validation.reshape(indep_len * num_test_examples)
-
-    x_validation = x_validation.astype('float64')
-    #x_validation /= 255.0
-    y_validation = keras_utils.to_categorical(y_validation, num_classes)
+    y_validation = y_validation.reshape(indep_len * num_test_examples, 
num_classes)
 
     return x_validation, y_validation
+
+CLASS_VALUES_COLNAME = "class_values"
+class FitInputValidator:
+    def __init__(self, source_table, validation_table, output_model_table,
+                 model_arch_table, dependent_varname, independent_varname,
+                 num_iterations):
+        self.source_table = source_table
+        self.validation_table = validation_table
+        self.output_model_table = output_model_table
+        self.model_arch_table = model_arch_table
+        self.dependent_varname = dependent_varname
+        self.independent_varname = independent_varname
+        self.num_iterations = num_iterations
+        self.source_summary_table = None
+        if self.source_table:
+            self.source_summary_table = add_postfix(
+                self.source_table, "_summary")
+        if self.output_model_table:
+            self.output_summary_model_table = add_postfix(
+                self.output_model_table, "_summary")
+        self.class_values_colname = CLASS_VALUES_COLNAME
 
 Review comment:
   Why do we need another variable for this ? Why can't we just use 
CLASS_VALUES_COLNAME?

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