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

Add utility for weight visualization #20225

Closed
wants to merge 3 commits into from

Conversation

shashaka
Copy link
Contributor

@shashaka shashaka commented Sep 7, 2024

Regarding the file inspection tool, I have added a utility for visualizing model weights. However, I believe it would be more versatile and widely applicable to implement this directly for models rather than focusing only on saved files. As a result, I have developed logic to display the model's weights using Matplotlib.

If it sounds good, I would like to propose integrating this functionality into plot_model, or perhaps creating a new utility method that accepts a model as a parameter.

here is my gist

@shashaka shashaka changed the title Add util for weight visualization Add utility for weight visualization Sep 7, 2024
@codecov-commenter
Copy link

codecov-commenter commented Sep 7, 2024

Codecov Report

Attention: Patch coverage is 0% with 64 lines in your changes missing coverage. Please review.

Project coverage is 79.26%. Comparing base (cb6ece3) to head (b103e0e).
Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
keras/src/utils/weight_visualization.py 0.00% 64 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #20225      +/-   ##
==========================================
- Coverage   82.12%   79.26%   -2.86%     
==========================================
  Files         501      502       +1     
  Lines       47440    47504      +64     
  Branches     8711     8725      +14     
==========================================
- Hits        38958    37655    -1303     
- Misses       6570     8086    +1516     
+ Partials     1912     1763     -149     
Flag Coverage Δ
keras 79.11% <0.00%> (-2.86%) ⬇️
keras-jax 62.43% <0.00%> (-2.85%) ⬇️
keras-numpy 57.62% <0.00%> (-0.23%) ⬇️
keras-tensorflow 63.81% <0.00%> (-2.85%) ⬇️
keras-torch 62.47% <0.00%> (-2.84%) ⬇️
keras.applications ?
keras.applications-jax ?
keras.applications-numpy ?
keras.applications-tensorflow ?
keras.applications-torch ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fchollet
Copy link
Member

fchollet commented Sep 8, 2024

Thanks for the PR! As for #19705, the main value would be to have an interactive, nice-looking HTML-based way to visualize the content of saved files and edit them. Visualizing weights is a separate problem, which we could leverage as part of the saved file visualizer, but it's not the main value there.

If you want to add a weight visualizer, we should make it clear where the boundaries between different "slices" of weights are. Right now everything is a big 2D grid. We should have slice separators and some indicator of which axes the slices map to.

But again, the main goal of #19705 is to see and edit the content of saved files interactively. Weight visualization is secondary.

@shashaka
Copy link
Contributor Author

shashaka commented Sep 8, 2024

Ok, I understand your thought. So, How about using load_model and save_model method to load,edit and save the model attribute and weight rather than using directly handle savedModel format?
I think this approach could be more versatile, since there could be several saving file format include .keras and .h5 in the future.
Plz feel free to share your opinion on this.

@fchollet
Copy link
Member

fchollet commented Sep 8, 2024

So, How about using load_model and save_model method to load,edit and save the model attribute and weight rather than using directly handle savedModel format?

It is not possible to load a model if it doesn't match your local code. You can only load it by modifying the saved file first.

The formats to target are the .keras and .weights.h5 formats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Closed/Rejected
Development

Successfully merging this pull request may close these issues.

4 participants