Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSK-273 Tensorflow IMDB Notebook #3

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

princyiakov
Copy link
Contributor

No description provided.

…. Added custom prediction function for giskard
@rabah-khalek
Copy link
Member

currently, with upload_model_and_df:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/giskard/client/project.py in _validate_model_is_pickleable(prediction_function)
    678         try:
--> 679             pickled_model = cloudpickle.dumps(prediction_function)
    680             unpickled_model = cloudpickle.loads(pickled_model)

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/cloudpickle/cloudpickle_fast.py in dumps(obj, protocol)
    101             cp = CloudPickler(file, protocol=protocol)
--> 102             cp.dump(obj)
    103             return file.getvalue()

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/cloudpickle/cloudpickle_fast.py in dump(self, obj)
    631         try:
--> 632             return Pickler.dump(self, obj)
    633         except RuntimeError as e:

/usr/local/Cellar/python@3.7/3.7.16/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pickle.py in dump(self, obj)
    436             self.framer.start_framing()
--> 437         self.save(obj)
    438         self.write(STOP)

/usr/local/Cellar/python@3.7/3.7.16/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pickle.py in save(self, obj, save_persistent_id)
    503         if f is not None:
--> 504             f(self, obj) # Call unbound method with explicit self
    505             return

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/cloudpickle/cloudpickle_fast.py in save_function(self, obj, name)
    818                 return self._save_reduce_pickle5(
--> 819                     *self._dynamic_function_reduce(obj), obj=obj
    820                 )

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/cloudpickle/cloudpickle_fast.py in _save_reduce_pickle5(self, func, args, state, listitems, dictitems, state_setter, obj)
    760             save(obj)  # simple BINGET opcode as obj is already memoized.
--> 761             save(state)
    762             write(pickle.TUPLE2)

/usr/local/Cellar/python@3.7/3.7.16/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pickle.py in save(self, obj, save_persistent_id)
    503         if f is not None:
--> 504             f(self, obj) # Call unbound method with explicit self
    505             return

/usr/local/Cellar/python@3.7/3.7.16/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pickle.py in save_tuple(self, obj)
    773             for element in obj:
--> 774                 save(element)
    775             # Subtle.  Same as in the big comment below.

/usr/local/Cellar/python@3.7/3.7.16/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pickle.py in save(self, obj, save_persistent_id)
    503         if f is not None:
--> 504             f(self, obj) # Call unbound method with explicit self
    505             return

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/dill/_dill.py in save_module_dict(pickler, obj)
   1185             pickler._first_pass = False
-> 1186         StockPickler.save_dict(pickler, obj)
   1187         logger.trace(pickler, "# D2")

/usr/local/Cellar/python@3.7/3.7.16/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pickle.py in save_dict(self, obj)
    858         self.memoize(obj)
--> 859         self._batch_setitems(obj.items())
    860 

/usr/local/Cellar/python@3.7/3.7.16/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pickle.py in _batch_setitems(self, items)
    884                     save(k)
--> 885                     save(v)
    886                 write(SETITEMS)

/usr/local/Cellar/python@3.7/3.7.16/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pickle.py in save(self, obj, save_persistent_id)
    503         if f is not None:
--> 504             f(self, obj) # Call unbound method with explicit self
    505             return

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/dill/_dill.py in save_module_dict(pickler, obj)
   1185             pickler._first_pass = False
-> 1186         StockPickler.save_dict(pickler, obj)
   1187         logger.trace(pickler, "# D2")

/usr/local/Cellar/python@3.7/3.7.16/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pickle.py in save_dict(self, obj)
    858         self.memoize(obj)
--> 859         self._batch_setitems(obj.items())
    860 

/usr/local/Cellar/python@3.7/3.7.16/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pickle.py in _batch_setitems(self, items)
    884                     save(k)
--> 885                     save(v)
    886                 write(SETITEMS)

/usr/local/Cellar/python@3.7/3.7.16/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pickle.py in save(self, obj, save_persistent_id)
    523             if reduce is not None:
--> 524                 rv = reduce(self.proto)
    525             else:

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/keras/engine/training.py in __reduce__(self)
    366                 pickle_utils.deserialize_model_from_bytecode,
--> 367                 (pickle_utils.serialize_model_as_bytecode(self),),
    368             )

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/keras/saving/pickle_utils.py in serialize_model_as_bytecode(model)
     72     except Exception as e:
---> 73         raise e
     74     else:

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/keras/saving/pickle_utils.py in serialize_model_as_bytecode(model)
     68         filepath = os.path.join(temp_dir, "model.keras")
---> 69         saving_lib.save_model(model, filepath)
     70         with open(filepath, "rb") as f:

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/keras/saving/experimental/saving_lib.py in save_model(model, filepath)
    152     except Exception as e:
--> 153         raise e
    154     finally:

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/keras/saving/experimental/saving_lib.py in save_model(model, filepath)
    142             inner_path="",
--> 143             visited_trackables=set(),
    144         )

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/keras/saving/experimental/saving_lib.py in _save_state(trackable, weights_handler, assets_handler, inner_path, visited_trackables)
    252                 inner_path=tf.io.gfile.join(inner_path, child_attr),
--> 253                 visited_trackables=visited_trackables,
    254             )

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/keras/saving/experimental/saving_lib.py in _save_container_state(container, weights_handler, assets_handler, inner_path, visited_trackables)
    316                 inner_path=tf.io.gfile.join(inner_path, name),
--> 317                 visited_trackables=visited_trackables,
    318             )

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/keras/saving/experimental/saving_lib.py in _save_state(trackable, weights_handler, assets_handler, inner_path, visited_trackables)
    244                 inner_path=tf.io.gfile.join(inner_path, child_attr),
--> 245                 visited_trackables=visited_trackables,
    246             )

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/keras/saving/experimental/saving_lib.py in _save_state(trackable, weights_handler, assets_handler, inner_path, visited_trackables)
    223     if hasattr(trackable, "_save_own_variables"):
--> 224         trackable._save_own_variables(weights_handler.make(inner_path))
    225     if hasattr(trackable, "_save_assets"):

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/keras/engine/base_layer.py in _save_own_variables(self, store)
   3432         for i, v in enumerate(all_vars):
-> 3433             store[f"{i}"] = v.numpy()
   3434 

AttributeError: 'VocabWeightHandler' object has no attribute 'numpy'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-36-7f56dfbe720a> in <module>
      8     classification_labels=[0,1],  # List of the classification labels of your prediction
      9     model_name='Tensorflow', # Name of the model
---> 10     dataset_name='test_data' # Name of the dataset
     11 )

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/giskard/client/project.py in upload_model_and_df(self, prediction_function, model_type, df, column_types, feature_names, target, model_name, dataset_name, classification_threshold, classification_labels)
    396             prediction_function,
    397             target,
--> 398             df,
    399         )
    400         data_res = self._post_data(column_types, data, dataset_name, raw_column_types, target)

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/giskard/client/project.py in _validate_model(self, classification_labels, classification_threshold, feature_names, model_type, prediction_function, target, validate_df)
    222             validate_df,
    223     ):
--> 224         prediction_function = self._validate_model_is_pickleable(prediction_function)
    225         transformed_pred_func = self.transform_prediction_function(
    226             prediction_function, feature_names

~/Documents/giskard/python-client/.venv/lib/python3.7/site-packages/giskard/client/project.py in _validate_model_is_pickleable(prediction_function)
    680             unpickled_model = cloudpickle.loads(pickled_model)
    681         except Exception:
--> 682             raise ValueError("Unable to pickle or unpickle model on Giskard")
    683         return unpickled_model
    684 

ValueError: Unable to pickle or unpickle model on Giskard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants