Uploaded image for project: 'Apache MADlib'
  1. Apache MADlib
  2. MADLIB-1336

Some compile and fit parameters not being passed properly to Keras

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • v1.16
    • None

    Description

      I suggest that we support the optional / mandatory rules of the underlying Keras compile and fit parameters.

      (1) I did not use a metrics parameter and it failed:

      SELECT madlib.madlib_keras_fit('mnist_train_packed',  -- source_table
                                     'model1', -- model
                                     'dependent_var',  -- dependent_varname
                                     'independent_var',  -- independent_varname
                                     'model_arch_library',  -- model_arch_table
                                     2,  -- model_arch_id
                                     $$ loss='categorical_crossentropy', optimizer='adam' $$,  -- compile_params
                                     $$ batch_size=128, epochs=4 $$,  -- fit_params
                                     1,  -- num_iterations
                                     FALSE,  -- use_gpu
                                     NULL,  -- validation_table
                                     'Frank',  -- name
                                     'A test model'  -- description
                                    );
      

      produces

      InternalError: (psycopg2.InternalError) plpy.SPIError: KeyError: 'metrics' (plpython.c:5038)  (seg0 slice1 10.128.0.41:40000 pid=31836) (plpython.c:5038)
      DETAIL:  
      Traceback (most recent call last):
        PL/Python function "fit_transition", line 6, in <module>
          return madlib_keras.fit_transition(**globals())
        PL/Python function "fit_transition", line 388, in fit_transition
        PL/Python function "fit_transition", line 71, in compile_and_set_weights
        PL/Python function "fit_transition", line 241, in compile_model
        PL/Python function "fit_transition", line 144, in parse_and_validate_compile_params
        PL/Python function "fit_transition", line 247, in validate_compile_param_types
      PL/Python function "fit_transition"
      CONTEXT:  Traceback (most recent call last):
        PL/Python function "madlib_keras_fit", line 21, in <module>
          madlib_keras.fit(**globals())
        PL/Python function "madlib_keras_fit", line 157, in fit
      PL/Python function "madlib_keras_fit"
       [SQL: "SELECT madlib.madlib_keras_fit('mnist_train_packed',  -- source_table\n                               'model1', -- model\n                               'dependent_var',  -- dependent_varname\n                               'independent_var',  -- independent_varname\n                               'model_arch_library',  -- model_arch_table\n                               2,  -- model_arch_id\n                               $$ loss='categorical_crossentropy', optimizer='adam' $$,  -- compile_params\n                               $$ batch_size=128, epochs=4 $$,  -- fit_params\n                               1,  -- num_iterations\n                               FALSE,  -- use_gpu\n                               NULL,  -- validation_table\n                               'Frank',  -- name\n                               'A test model'  -- description\n                              );"]
      

      (2) Errors on loss parameter which is optional:

      madlib=# SELECT madlib.madlib_keras_fit('mnist_train_packed',  -- source_table
      madlib(#                                'model1', -- model
      madlib(#                                'dependent_var',  -- dependent_varname
      madlib(#                                'independent_var',  -- independent_varname
      madlib(#                                'model_arch_library',  -- model_arch_table
      madlib(#                                2,  -- model_arch_id
      madlib(#                                $$ optimizer='adam' $$,  -- compile_params
      madlib(#                                $$ $$,  -- fit_params
      madlib(#                                1,  -- num_iterations
      madlib(#                                FALSE,  -- use_gpu
      madlib(#                                NULL,  -- validation_table
      madlib(#                                'Frank',  -- name
      madlib(#                                'A test model'  -- description
      madlib(#                               );
      INFO:  Model architecture size: 1KB
      CONTEXT:  PL/Python function "madlib_keras_fit"
      INFO:  Model state (serialized) size: 2MB
      CONTEXT:  PL/Python function "madlib_keras_fit"
      ERROR:  plpy.SPIError: KeyError: 'loss' (plpython.c:5038)  (seg0 slice1 10.128.0.41:40000 pid=1039) (plpython.c:5038)
      DETAIL:  
      Traceback (most recent call last):
        PL/Python function "fit_transition", line 6, in <module>
          return madlib_keras.fit_transition(**globals())
        PL/Python function "fit_transition", line 388, in fit_transition
        PL/Python function "fit_transition", line 71, in compile_and_set_weights
        PL/Python function "fit_transition", line 241, in compile_model
        PL/Python function "fit_transition", line 136, in parse_and_validate_compile_params
        PL/Python function "fit_transition", line 187, in parse_loss
      PL/Python function "fit_transition"
      CONTEXT:  Traceback (most recent call last):
        PL/Python function "madlib_keras_fit", line 21, in <module>
      

      (3) All fit params are optional so should be able to pass NULL

      madlib=# SELECT madlib.madlib_keras_fit('mnist_train_packed',  -- source_table
      madlib(#                                'model1', -- model
      madlib(#                                'dependent_var',  -- dependent_varname
      madlib(#                                'independent_var',  -- independent_varname
      madlib(#                                'model_arch_library',  -- model_arch_table
      madlib(#                                2,  -- model_arch_id
      madlib(#                                $$ optimizer='adam' $$,  -- compile_params
      madlib(#                                NULL,  -- fit_params
      madlib(#                                1,  -- num_iterations
      madlib(#                                FALSE,  -- use_gpu
      madlib(#                                NULL,  -- validation_table
      madlib(#                                'Frank',  -- name
      madlib(#                                'A test model'  -- description
      madlib(#                               );
      ERROR:  TypeError: cannot concatenate 'str' and 'NoneType' objects (plpython.c:5038)
      CONTEXT:  Traceback (most recent call last):
        PL/Python function "madlib_keras_fit", line 21, in <module>
          madlib_keras.fit(**globals())
        PL/Python function "madlib_keras_fit", line 127, in fit
      PL/Python function "madlib_keras_fit"
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            fmcquillan Frank McQuillan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: