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

Gracefully handle legacy Sequential configs #11280

Merged
merged 2 commits into from Oct 2, 2018
Merged

Gracefully handle legacy Sequential configs #11280

merged 2 commits into from Oct 2, 2018

Conversation

GabrielBianconi
Copy link
Contributor

@GabrielBianconi GabrielBianconi commented Oct 2, 2018

Summary

In a recent change to Keras (#11133) incorporated in 2.2.3, name was added to the Sequential config. From the release notes:

Breaking Changes
Modify the return value of Sequential.get_config(). Previously, the return value was a list of the config dictionaries of the layers of the model. Now, the return value is a dictionary with keys layers, name, and an optional key build_input_shape. The old config is equivalent to new_config['layers']. This makes the output of get_config consistent across all model classes.

However, Keras now raises an UnboundLocalError exception whenever loading a legacy configuration file. In from_config, name can be undefined if this variable is not present in the config, and in line 298 of the modified file, is used by model = cls(name=name).

I modified the code such that legacy configs still load, but throws a warning. Maybe a different behavior is desired, but Keras, in my opinion, shouldn't crash like this (especially without any warnings).

Related Issues

#11133

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)

@GabrielBianconi GabrielBianconi changed the title Graciously handle legacy Sequential configs Gracefully handle legacy Sequential configs Oct 2, 2018
Copy link
Member

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

Sounds good, thanks.

@fchollet fchollet merged commit b80f3bd into keras-team:master Oct 2, 2018
@gabrieldemarmiesse
Copy link
Contributor

Maybe we should have migration tests to ensure that we don't break the loading of saved models. I am unsure how to implement this though.

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.

None yet

3 participants