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

keras.src.saving.pickle_utils.deserialize_model_from_bytecode not found, results in Defer #38

Open
IanButterworth opened this issue Dec 4, 2023 · 2 comments

Comments

@IanButterworth
Copy link

IanButterworth commented Dec 4, 2023

I'm guessing this means some keras support needs to be added.

julia> params = Pickle.Torch.THload("foo.pth")
Defer(:reduce, Defer(:keras.src.saving.pickle_utils.deserialize_model_from_bytecode), UInt8[0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00  …  0xb2, 0x00, 0x00, 0x00, 0xc6, 0xa5, 0xee, 0x02, 0x00, 0x00])

If so, can you provide guidance. I'm happy to PR

@chengchingwen
Copy link
Owner

You would need to implement a julia function that perform keras.src.saving.pickle_utils.deserialize_model_from_bytecode on UInt8[0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00 … 0xb2, 0x00, 0x00, 0x00, 0xc6, 0xa5, 0xee, 0x02, 0x00, 0x00] and register that to the unpickler (TorchPickler().mt["keras.src.saving.pickle_utils.deserialize_model_from_bytecode"] = julia_impl_deserialize_model_from_bytecode). Though I'm not sure what exactly keras.src.saving.pickle_utils.deserialize_model_from_bytecodedo.

@chengchingwen
Copy link
Owner

https://github.com/keras-team/keras/blob/601488fd4c1468ae7872e132e0f1c9843df54182/keras/saving/pickle_utils.py#L46

https://github.com/keras-team/keras/blob/601488fd4c1468ae7872e132e0f1c9843df54182/keras/saving/saving_lib.py#L233

The bytes seem to be raw bytes of a zipfile, which contains the configurations and weights stored in either H5 or Npz. The load_model function would directly construct the keras model from the configurations and weights.

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

2 participants