Fix ProgressBoard AttributeError and unconditional label assignment in torch/tensorflow/mxnet backends#2706
Open
Chessing234 wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
In
ProgressBoard.draw()across the PyTorch, TensorFlow, and MXNet backends, the label-setting code is:Two problems:
self.xis not an attribute ofProgressBoard— it is never stored on the instance. WhenxlabelisNone(the default) or an empty string, this line raisesAttributeError: 'ProgressBoard' object has no attribute 'x'.The truthiness check
if not self.xlabeltreats an explicitly-supplied empty string""as equivalent toNone, unintentionally overwriting it.Root cause
The fallback
self.xlabel = self.xis a dead code remnant;xis a local parameter ofdraw()not a stored attribute. WhenxlabelisNonethe intent is simply to omit the axis label, not to substitute the numeric x-coordinate.The same bug was fixed in
d2l/jax.pyby PR #2704/#2705 but those PRs only touched the JAX backend.Fix
Guard both
set_xlabelandset_ylabelwith explicitis not Nonechecks (matching the JAX fix) in all three remaining backends:torch.py,tensorflow.py, andmxnet.py.