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

BugFix of "AttributeError: 'ProgbarLogger' object has no attribute 'target'" (or 'log_values') error (#12898) (#12893) (#8944) #12899

Closed
wants to merge 3 commits into from

Conversation

mrjj
Copy link

@mrjj mrjj commented May 31, 2019

This Change set is fixing two missing attribute bugs in callback.ProgbarLogger class

Related changes:

  • Cases of regression are covered by tests.
  • Some potential bugs with same nature are prevented and covered by manifestation checks.
  • run with empty data array (but having valid shape) is now handled properly
    and yielding related warnings on callback and training routine level without execution fail

Note:
Changes that affect ProgbarLogger should be aware of following things:

  • proper target initialisation is requiring two attributes: params and use_steps to be defined
  • use_steps is guaranteed attribute the is set in the constructor (but could be altered after object instantiation. It's currently safe condition.
  • class params attribute could be altered between initialisation and training start. And current logic is made to be aware of this
  • we don't have params initialisation in constructor, this attribute will be assigned on call of set_params of base class somewhere on caller level (no strict guarantees :( )
  • seen attribute is working in pair with target during log_values initialisation and their initialisation should be under the equal condition, currently thats not true
  • if self.seen < self.target condition is being checked whenever verbose mode value so both of them should be initialised without any conditions
  • if self.seen < self.target is checking for training iteration being not finished but in case of degenerate case with zero length it will not be called and log_values will stay not initialised but i don't see any explicit logic preventing using it on exit from 0-length training cycle and potentially it is the bug of some kind that is prevented on caller logic level
  • progbar attribute initialisation is definitely related to output verbosity (log values accumulation are not) and should be left under verbosity condition

Summary

Related Issues

PR Overview

  • This PR requires new unit tests [y/n] (make sure tests are included)
  • This PR requires to update the documentation [y/n] (make sure the docs are up-to-date)
  • This PR is backwards compatible [y/n]
  • This PR changes the current API [y/n] (all API changes need to be approved by fchollet)

…arget'" (or 'log_values') error (keras-team#12898) (keras-team#12893) (keras-team#8944)

This Change set is fixing two missing attribute bugs:
* AttributeError: 'ProgbarLogger' object has no attribute 'target' keras-team#12898
  Abstract reproduction scenario is provided in ticket
* AttributeError: 'ProgbarLogger' object has no attribute 'log_values' keras-team#3657
* AttributeError: 'ProgbarLogger' object has no attribute 'log_values' keras-team#8944 (dup)

Related changes:
* Cases of regression are covered by tests.
* Some potential bugs with same nature are prevented and covered by manifestation checks.
* run with empty data array (but having valid shape) is now handled properly
  and yielding related warnings on callback and training routine level without execution fail

Note:
Changes that affect `ProgbarLogger` should be aware of following things:
* proper target initialisation is requiring two attributes: `params` and `use_steps` to be defined
* `use_steps` is guaranteed attribute the is set in the constructor (but could be altered after object instantiation. It's currently safe condition.
* class `params` attribute could be altered between initialisation and training start. And current logic is made to be aware of this
* we don't have `params` initialisation in constructor, this attribute will be assigned on call of `set_params` of base class somewhere on caller level (no strict guarantees :( )
* `seen` attribute is working in pair with `target` during `log_values` initialisation and their initialisation should be under the equal condition, currently thats not true
* `if self.seen < self.target` condition is being checked whenever verbose mode value so both of them should be initialised without any conditions
* `if self.seen < self.target` is checking for training iteration being not finished but in case of degenerate case with zero length it will not be called and `log_values` will stay not initialised but i don't see any explicit logic preventing using it on exit from 0-length training cycle and potentially it is the bug of some kind that is prevented on caller logic level
* `progbar` attribute initialisation is definitely related to output verbosity (log values accumulation are not) and should be left under verbosity condition
@mrjj
Copy link
Author

mrjj commented Jun 19, 2019

Guys, any assistance with landing, please?
I really don't want to have Keras in downstream or do workaround coding every time 😿

@@ -567,19 +573,22 @@ def __init__(self, count_mode='samples',
def on_train_begin(self, logs=None):
self.verbose = self.params['verbose']
self.epochs = self.params['epochs']
self.log_values = []
if self.target is 0:
Copy link
Member

Choose a reason for hiding this comment

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

You can remove the warning, since it will not be informative for the user (it assumes too much context)

log_values = None
target = 0
seen = 0
progbar = None
Copy link
Member

Choose a reason for hiding this comment

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

Instance attributes should never be class attributes. They should be defined in init. You may not realize it, but everything you define at the class level (like here) is shared across instances.

@HunterMcGushion
Copy link

Sorry if I'm stepping on any toes by jumping in, but it looks like the two failed tests on Travis should pass if you rebase this on top of the current Keras master. Specifically, 3e77ab6 seems to do the trick.

@fchollet
Copy link
Member

Closing outdated PR.

@fchollet fchollet closed this Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants