You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@madlib.apache.org by ok...@apache.org on 2023/09/05 16:50:39 UTC
[madlib] 02/05: DL: Update get_state_to_return to always return bytea
This is an automated email from the ASF dual-hosted git repository.
okislal pushed a commit to branch madlib2-master
in repository https://gitbox.apache.org/repos/asf/madlib.git
commit 40dfa0e3810b2f8d070941ba8053cc7b7886f169
Author: Orhan Kislal <ok...@apache.org>
AuthorDate: Fri Sep 1 20:34:48 2023 +0300
DL: Update get_state_to_return to always return bytea
get_state_to_return returned bytea in some cases and a single float in
others. The float value is not actually used so it did not break the
process. However, this still causes python instability and errors in
some cases. This commit fixes the issue by converting the float value to
bytea just like the rest of the options.
---
src/ports/postgres/modules/deep_learning/madlib_keras.py_in | 2 +-
.../modules/deep_learning/test/unit_tests/test_madlib_keras.py_in | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/ports/postgres/modules/deep_learning/madlib_keras.py_in b/src/ports/postgres/modules/deep_learning/madlib_keras.py_in
index 5a99f129..2bd98c4f 100644
--- a/src/ports/postgres/modules/deep_learning/madlib_keras.py_in
+++ b/src/ports/postgres/modules/deep_learning/madlib_keras.py_in
@@ -800,7 +800,7 @@ def get_state_to_return(segment_model, is_last_row, is_multiple_model, agg_image
new_state = serialize_state_with_nd_weights(
agg_image_count, updated_model_weights)
else:
- new_state = float(agg_image_count)
+ new_state = np.float32(agg_image_count).tostring()
return new_state
diff --git a/src/ports/postgres/modules/deep_learning/test/unit_tests/test_madlib_keras.py_in b/src/ports/postgres/modules/deep_learning/test/unit_tests/test_madlib_keras.py_in
index ab8dc383..3da8549d 100644
--- a/src/ports/postgres/modules/deep_learning/test/unit_tests/test_madlib_keras.py_in
+++ b/src/ports/postgres/modules/deep_learning/test/unit_tests/test_madlib_keras.py_in
@@ -127,7 +127,7 @@ class MadlibKerasFitEvalTransitionTestCase(unittest.TestCase):
image_count = kwargs['GD']['agg_image_count']
self.assertEqual(ending_image_count, image_count)
- image_count = new_state
+ image_count = np.fromstring(new_state,dtype=np.float32)[0]
self.assertEqual(ending_image_count, image_count)
def _test_fit_transition_multiple_model_no_cache_first_buffer_pass(self, **kwargs):
@@ -179,7 +179,7 @@ class MadlibKerasFitEvalTransitionTestCase(unittest.TestCase):
self.total_images_per_seg, self.accessible_gpus_for_seg,
self.dummy_prev_weights, **kwargs)
- image_count = new_state
+ image_count = np.fromstring(new_state,dtype=np.float32)[0]
self.assertEqual(ending_image_count, image_count)
def _test_fit_transition_multiple_model_no_cache_middle_buffer_pass(self,