Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'keras.backend' has no attribute 'image_dim_ordering'

I tried to execute some tutorial transfer learning project. But I've got attribute error.

I checked my tensorflow and keras version.

tensorflow : 1.14.0 keras : 2.2.5

and python 3.6.9 version.

the code is here.

if(K.image_dim_ordering() == 'th'):
  input_tensor = Input(shape=(3, 299, 299))

error message here.

AttributeError: module 'keras.backend' has no attribute 'image_dim_ordering'
like image 796
kangfox Avatar asked Sep 05 '19 00:09

kangfox


2 Answers

keras.backend.common module has image_dim_ordering()

if(K.common.image_dim_ordering() == 'th'):

    input_tensor = Input(shape=(3, 299, 299))
like image 104
jessejames67 Avatar answered Oct 03 '22 08:10

jessejames67


Replace image_dim_ordering to image_data_format

if(K.image_dim_ordering() == 'th'): 
  input_tensor = Input(shape=(3, 299, 299))

change the above code to

if K.image_data_format() == 'th':
  input_tensor = Input(shape=(3, 299, 299))

Keras Backend utilities

like image 34
Vidya Ganesh Avatar answered Oct 03 '22 07:10

Vidya Ganesh