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

Refactoring: Used the function normalize_data_format to remove some code. #10690

Merged
merged 2 commits into from
Jul 19, 2018
Merged

Refactoring: Used the function normalize_data_format to remove some code. #10690

merged 2 commits into from
Jul 19, 2018

Conversation

gabrieldemarmiesse
Copy link
Contributor

@gabrieldemarmiesse gabrieldemarmiesse commented Jul 15, 2018

Summary

Quite a lot of code can be removed by doing this. Would you want me to split it into multiple smaller PRs?

Related Issues

PR Overview

To solve the issue of cyclical imports, I moved the normalized_data_format in backend/common.py. I think it makes sense for the implementation to be there overall since it's tightly connected to the data_format given by the backend. I left the other implementation to avoid breaking anything.

  • 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)

@gabrieldemarmiesse gabrieldemarmiesse changed the title Refectoring: Used the function normalize_data_format to remove some code. Refactoring: Used the function normalize_data_format to remove some code. Jul 15, 2018
…the implementation to keras/backend/common.py.
Copy link
Collaborator

@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.

Thanks for the PR.

@@ -8,6 +8,9 @@
import numpy as np
from .. import backend as K

# Legacy import
from ..backend import normalize_data_format
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not part of the public API, you don't need to import it here.

@@ -99,6 +99,7 @@
'deserialize',
'get',
'set_image_dim_ordering',
'normalize_data_format',
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not part of the public API, it shouldn't be documented.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. This is why it's in the EXCLUDE set here.

@@ -4,7 +4,8 @@

import cntk as C
import numpy as np
from .common import floatx, epsilon, image_dim_ordering, image_data_format
from .common import floatx, epsilon
from .common import image_data_format, normalize_data_format
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use one import per line from now on.

@@ -147,6 +147,37 @@ def set_image_data_format(data_format):
_IMAGE_DATA_FORMAT = str(data_format)


def normalize_data_format(value):
"""Check that the value correspond to a valid data format.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Checks

"""Check that the value correspond to a valid data format.

# Arguments
value: string or None. `'channels_first'` or `'channels_last'`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Capitalize start of argument descriptions ("String or...")

Copy link
Collaborator

@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.

LGTM, thanks

@fchollet fchollet merged commit d40656e into keras-team:master Jul 19, 2018
@gabrieldemarmiesse gabrieldemarmiesse deleted the using_check_data_format branch September 18, 2018 06:33
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.

2 participants