Keras: I get AttributeError on tf 1.0.1 running tensorflow on keras

Created on 15 Mar 2017  路  4Comments  路  Source: keras-team/keras

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?

stale

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' to K.image_dim_ordering() == 'th' and it will work fine.

All 4 comments

"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/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zygmuntz picture zygmuntz  路  3Comments

braingineer picture braingineer  路  3Comments

nryant picture nryant  路  3Comments

snakeztc picture snakeztc  路  3Comments

oweingrod picture oweingrod  路  3Comments