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

h5py==3.0.0 causes model save issues in tf 2.1.0 #487

Closed
zanshuxun opened this issue Aug 5, 2022 · 1 comment
Closed

h5py==3.0.0 causes model save issues in tf 2.1.0 #487

zanshuxun opened this issue Aug 5, 2022 · 1 comment

Comments

@zanshuxun
Copy link
Collaborator

zanshuxun commented Aug 5, 2022

Describe the bug(问题描述)
model.save_weights causes TypeError: a bytes-like object is required, not 'str'.

Related issue: h5py==3.0.0 causes issues with keras model loads in tensorflow 2.1.0 (tensorflow/tensorflow#44467).

Suggested sulotion:

pin to h5py==2.10.0 this for all TF >= 2.1

Traceback (most recent call last):
  File "/Users/zsx/Code/DeepCTR/examples/run_classification_criteo.py", line 53, in <module>
    model.save_weights('deepfm_weights.h5')
  File "/Users/zsx/anaconda3/envs/tf2.3/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/network.py", line 1107, in save_weights
    hdf5_format.save_weights_to_hdf5_group(f, self.layers)
  File "/Users/zsx/anaconda3/envs/tf2.3/lib/python3.6/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py", line 631, in save_weights_to_hdf5_group
    param_dset = g.create_dataset(name, val.shape, dtype=val.dtype)
  File "/Users/zsx/anaconda3/envs/tf2.3/lib/python3.6/site-packages/h5py/_hl/group.py", line 143, in create_dataset
    if '/' in name:
TypeError: a bytes-like object is required, not 'str'

To Reproduce(复现步骤)
There are two ways to reproduce the behavior:

  • add model.save_weights('deepfm_weights.h5') in the end of run_classification_criteo.py

or

  • run the DeepFM_test.py

Operating environment(运行环境):

  • python version 3.6.5
  • tensorflow version 2.1.0
  • deepctr version 0.8.2
  • h5py version 3.0.0

Additional context
Add any other context about the problem here.

@zanshuxun
Copy link
Collaborator Author

zanshuxun commented Aug 5, 2022

Resolved in DeepCTR 0.8.3 by setting h5py==2.10.0:

'h5py==2.10.0', 'requests'

@zanshuxun zanshuxun changed the title model.save_weights causes TypeError: a bytes-like object is required, not 'str' h5py==3.0.0 causes model save issues in tf 2.1.0 Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant