kaknikhil commented on a change in pull request #393: DL: Add support for
reporting various metrics in fit/evaluate
URL: https://github.com/apache/madlib/pull/393#discussion_r285702275
##########
File path: src/ports/postgres/modules/deep_learning/madlib_keras.py_in
##########
@@ -638,21 +611,21 @@ def internal_keras_eval_transition(state, dependent_var,
independent_var,
SD = kwargs['SD']
device_name = get_device_name_and_set_cuda_env(gpus_per_host,
current_seg_id)
- agg_loss, agg_accuracy, agg_image_count = state
+ agg_loss, agg_metric, agg_image_count = state
if not agg_image_count:
if not is_platform_pg():
set_keras_session(gpus_per_host, segments_per_host)
model = model_from_json(model_architecture)
model_shapes = madlib_keras_serializer.get_model_shapes(model)
- _, _, _, model_weights = madlib_keras_serializer.deserialize_weights(
+ _, model_weights = madlib_keras_serializer.deserialize_weights(
model_data, model_shapes)
model.set_weights(model_weights)
with K.tf.device(device_name):
compile_model(model, compile_params)
SD['segment_model'] = model
# These should already be 0, but just in case make sure
- agg_accuracy = 0
+ agg_metric = 0
Review comment:
Calling madlib_keras_fit without any metrics fails with the following error
```
SELECT
madlib.madlib_keras_fit('cifar_10_sample_batched','keras_saved_out','model_arch',1,
$$ optimizer=SGD(lr=0.01, decay=1e-6, nesterov=True),
loss='categorical_crossentropy'$$::text,
$$ batch_size=2, epochs=1, verbose=0 $$::text,3);
ERROR: plpy.SPIError: TypeError: 'numpy.float64' object is not iterable
(plpython.c:5038) (seg0 slice1 127.0.0.1:25432 pid=95971) (plpython.c:5038)
DETAIL:
Traceback (most recent call last):
PL/Python function "internal_keras_eval_transition", line 6, in <module>
return madlib_keras.internal_keras_eval_transition(**globals())
PL/Python function "internal_keras_eval_transition", line 639, in
internal_keras_eval_transition
PL/Python function "internal_keras_eval_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 216, in fit
PL/Python function "madlib_keras_fit", line 343, in
compute_loss_and_metrics
PL/Python function "madlib_keras_fit", line 602, in
get_loss_metric_from_keras_eval
PL/Python function "madlib_keras_fit"
```
We should add a dev-check test for this use case and also for when metrics
is passed as an empty string ` metrics=['']`
----------------------------------------------------------------
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