Fix plot_model producing empty output with rankdir=LR#22277
Fix plot_model producing empty output with rankdir=LR#22277rstar327 wants to merge 1 commit intokeras-team:masterfrom
Conversation
Summary of ChangesHello @rstar327, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical rendering bug in the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses the issue of plot_model producing empty outputs when using horizontal layouts (rankdir="LR" or "RL"). The solution to dynamically set splines="curved" for these layouts, while retaining "ortho" for vertical ones, is a pragmatic and correct fix. This change significantly improves the utility and reliability of the plot_model function for users, aligning with the Keras API design guidelines to minimize cognitive load and bake best practices into the API.
| # "ortho" splines are incompatible with horizontal (LR/RL) layouts | ||
| # in graphviz, producing empty output for complex models. |
There was a problem hiding this comment.
The inline comment explaining the incompatibility between "ortho" splines and horizontal layouts is very helpful. For better discoverability and long-term maintainability, consider moving this explanation to the docstring of the rankdir parameter in the model_to_dot function. This ensures that users and future maintainers can easily find this crucial information when consulting the function's documentation.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #22277 +/- ##
===========================================
+ Coverage 71.44% 83.02% +11.57%
===========================================
Files 594 594
Lines 65029 65031 +2
Branches 10174 10175 +1
===========================================
+ Hits 46461 53991 +7530
+ Misses 16105 8419 -7686
- Partials 2463 2621 +158
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Fixes
plot_modelproducing empty/blank output when usingrankdir="LR"(or"RL").The root cause is that graphviz's
splines="ortho"(orthogonal edge routing) is incompatible with horizontal layouts (rankdir="LR"/"RL"). For complex models like UNets with many skip connections, graphviz silently fails to render anything.The fix uses
splines="curved"for horizontal layouts while keepingsplines="ortho"for the default vertical (TB/BT) layouts.Fixes #21801