-
Notifications
You must be signed in to change notification settings - Fork 19.4k
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
Implement tool for saved Keras model files inspection, diff and patching #19768
Conversation
It consists of three sub features, that allow: Visualization of the contents of .keras and .weights.h5 files, where you can further expand the contents up until the weights of the file. Diff of a model compared to a reference model, being presented side by side with the differences highlighted. Patching a model, where it is possible to change a layer's name and changing a specified weight of a model. Co-authored-by: Pedro Curto <pedro.a.curto@tecnico.ulisboa.pt>
Thanks for the PR! Do you have a Colab notebook that demos the new features? |
Yes, here I couldn't implement the changes in the saved weights file, only in a .keras file. |
Great work! Here are some things we should do.
editor = KerasFileEditor(filepath)
editor.list_layer_paths() # Return all layer paths
editor.layer_info(layer_path) # Show weight structure for this layer
editor.edit_layer(layer_path, new_name=..., new_vars=...)
editor.write_out(filepath)
They aren't very different -- the weights file is one of the files present in the .keras file. You only need to implement these features for the weights file, then the same code will also work for the .keras file. |
Thank you very much for your feedback, we really appreciate it! We're currently on our degree's final two weeks, so everything is very intensive right now and we barely have any time because of the projects. We would really like to make those changes and get back to you because we enjoyed working on this feature and would like it to be as good as possible and according to your needs and the specification. We will get back to you and make the required changes starting next week, if that is ok with you. Again, thanks for your time, patience and feedback! |
Sure -- there's no rush! Thanks for working on this! |
Implemented the solicited changes: Changed inspect_file to differentiate between shell mode (with plain text with text color tags) and notebook mode (using HTML) Changed the diff functionality to match the solicited requirements (comparing model structure and weight structure according to specification in PR discussion) and have clearer and better output Reworked the edit tool to be a class and have the solicited methods (listing layer paths, showing weight structure, editing layers and writing out to a path) Co-authored-by: Pedro Curto <pedro.a.curto@tecnico.ulisboa.pt>
Hello. Sorry for taking so long. |
Thanks for the update -- the functionality looks great! I think the interface could look more professional though. Maybe we can first focus on the HTML version of the interface (for Colab / notebooks) and then we can figure out later what the CLI / text-only version should look like? |
Glad you liked it! |
Sure. What you had at the very end of this notebook was quite nice, for instance. Penzai is also reasonably nice. |
Just to clarify, you would like us to make the compare_models interface look more professional, like the inspect_file interface? |
Yes, exactly -- preferably something with interactive HTML. It could list the layers for which there was a discrepancy, and clicking on the layer would reveal the issue. Interactiveness enables greater UX clarity. |
Okay, thank you for explaining. Me and my friend are currently working so this will only be possible to do in our free time, but we will keep you updated if there is progress! |
This PR is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you. |
I'd really like to make the required changes but it's been impossible to have time, so I'm commenting for the PR not to close. |
Thank you for the contributions here so far -- we merged a subset of this feature in |
It consists of three sub features, that allow:
Visualization of the contents of .keras and .weights.h5 files in a notebook, where you can further expand the contents up until the weights of the file. Diff of a model compared to a reference model, being presented side by side with the differences highlighted. Patching a model, where it is possible to change a layer's name and changing a specified weight of a model.
Please let us know if this is what you had in mind.
closes #19705