I am running below code:
from keras import backend as K
if K.image_data_format() == 'channels_first':
input_shape = (3, img_width, img_height)
else:
input_shape = (img_width, img_height, 3)
Getting this error:
AttributeError: module 'keras.backend' has no attribute 'image_data_format'
How to resolve this?
"image_dim_ordering" is a legacy variable, so I guess you might be using an old version of Keras. You could change K.image_data_format() == 'channels_first' to K.image_dim_ordering() == 'th' and it will work fine.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.
hi @egrinstein thanks .
I meet the same question.
But i have upgrade the keras to 2.1.5 bypip install keras --upgrade
You say my keras's version is old ,then cause this question.
It's so wired.
thanks again.
thanks again. I used the old backend. SO i use the new backend and it work.https://keras.io/backend/
Most helpful comment
"image_dim_ordering" is a legacy variable, so I guess you might be using an old version of Keras. You could change
K.image_data_format() == 'channels_first'toK.image_dim_ordering() == 'th'and it will work fine.