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 assert statement to check model structure on model_visualization_test #20208

Merged
merged 2 commits into from
Sep 5, 2024

Conversation

shashaka
Copy link
Contributor

@shashaka shashaka commented Sep 4, 2024

To verify the model's structure, I added a method that parses the model into a dictionary and included an assert statement to validate it.
Additionally, I assigned fixed names to each layer in the model to ensure consistency when referencing them.

@codecov-commenter
Copy link

codecov-commenter commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.37%. Comparing base (dbad6b0) to head (08bce13).
Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #20208   +/-   ##
=======================================
  Coverage   79.36%   79.37%           
=======================================
  Files         501      501           
  Lines       47380    47435   +55     
  Branches     8706     8710    +4     
=======================================
+ Hits        37604    37652   +48     
- Misses       8015     8020    +5     
- Partials     1761     1763    +2     
Flag Coverage Δ
keras 79.22% <ø> (+<0.01%) ⬆️
keras-jax 62.51% <ø> (+0.01%) ⬆️
keras-numpy 57.70% <ø> (+0.02%) ⬆️
keras-tensorflow 63.90% <ø> (+0.01%) ⬆️
keras-torch 62.56% <ø> (+0.01%) ⬆️

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.

model = keras.Model(inputs, outputs)

edge_dict = get_edge_dict(model_to_dot(model))

assert edge_dict["input_1 (InputLayer)"] == "dense_3 (Dense)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such statements should be made via self.assertEqual

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the source code as your advice.
Additionally, I removed the main statement also, since, I think it can be replaced by just running ModelVisualizationTest class by pytest.

@fchollet
Copy link
Member

fchollet commented Sep 5, 2024

@shashaka -- if you'd like to work on an impactful feature, would you consider taking over #19768 ?

@shashaka
Copy link
Contributor Author

shashaka commented Sep 5, 2024

@fchollet Ok. After resoling this MR,I will look into that issue. Thanks.

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Sep 5, 2024
@fchollet fchollet merged commit a6cc559 into keras-team:master Sep 5, 2024
6 checks passed
@google-ml-butler google-ml-butler bot removed ready to pull Ready to be merged into the codebase kokoro:force-run labels Sep 5, 2024
@shashaka shashaka deleted the assert_model_visualization branch September 5, 2024 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants