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

ImportError: cannot import name 'normalize_data_format' #35

Open
zeeshannisar opened this issue Nov 23, 2018 · 8 comments
Open

ImportError: cannot import name 'normalize_data_format' #35

zeeshannisar opened this issue Nov 23, 2018 · 8 comments

Comments

@zeeshannisar
Copy link

I have read your article and its pretty nice enough to understand. Thank you for your contribution. When I a trying to train at my own using your code it gives me an Import Error like following. I am using google Colab environment. Having some search over the error i got that the following line is compatible to keras version==2.2.2. I have also installed that yet not solved with the error. Please help me to get over it. By default keras version installed in colab is 2.2.4

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-47-f8ce7e15cf87> in <module>()
      9 from keras.layers.merge import Add
     10 from keras.utils import conv_utils
---> 11 from keras.utils.conv_utils import normalize_data_format
     12 
     13 from keras.layers.core import Dropout

ImportError: cannot import name 'normalize_data_format'

---------------------------------------------------------------------------
@ruixv
Copy link

ruixv commented Dec 16, 2018

Hi, I met the same question and solved it using the method here: keras-team/keras-contrib#298 (comment)

#from keras.backend.common import normalize_data_format
from keras.utils.conv_utils import normalize_data_format

that is:
self.data_format= common.normalize_data_format(data_format)

@zhangxiaoya
Copy link

I used keras 2.1.3 and tensorflow 1.5 and solved it.

@gdyshi
Copy link

gdyshi commented Apr 17, 2019

In the new version of keras, this function was not put in conv_utils, but in the backend.
I sloved by

import keras.backend as K
and replace "conv_utils.normalize_data_format" with "K.normalize_data_format"

@docongminh
Copy link

I used keras 2.1.3 and tensorflow 1.5 and solved it.
thanks ! It work

@sailfish009
Copy link

keras version: 2.4.3
K.common.normalize_data_format(data_format)
AttributeError: module 'keras.backend' has no attribute 'common'

@sailfish009
Copy link

https://stackoverflow.com/questions/53442190/importerror-cannot-import-name-normalize-data-format

import keras.backend as K
def normalize_data_format(value):
    if value is None:
        value = K.image_data_format()
    data_format = value.lower()
    if data_format not in {'channels_first', 'channels_last'}:
        raise ValueError('The `data_format` argument must be one of '
                         '"channels_first", "channels_last". Received: ' +
                         str(value))
    return data_format

@superran1
Copy link

I meet same problem with you ,keras version is 2.4.3.

@gevindharmalim
Copy link

can someone tell me how to solve it in keras version 2.4.3

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

No branches or pull requests

8 participants