Obtain_input_shape() got an unexpected keyword argument 'dim_ordering'

HI,

While running the code
model = VGG16_Avg(include_top=False)
in Neural Transfer notebook i am getting the error as:
ypeError Traceback (most recent call last)
in ()
----> 1 model = VGG16_Avg(include_top=False)

~/nbs/vgg16_avg.py in VGG16_Avg(include_top, weights, input_tensor, input_shape, classes)
36 min_size=48,
37 data_format=K.image_data_format(),
—> 38 include_top=include_top)
39
40 if input_tensor is None:

TypeError: _obtain_input_shape() got an unexpected keyword argument ‘dim_ordering’

As per the suggestion in the post i changed the ‘dim_ordering’ part in the code to ‘data_format’, but am still getting the same error.
input_shape = _obtain_input_shape(input_shape,
default_size=224,
min_size=48,
data_format=K.image_data_format(),
include_top=include_top)

I also changed

load weights

if weights == 'imagenet':
    if K.image_dim_ordering() == 'th':

to K.image_data_format() == ‘th’:
but to no avail.

I am using the below commands for installing all the softwares in my p2.xlarge machine:-

  1. sudo apt update
  2. sudo apt upgrade
  3. cd downloads/
  4. wget https://repo.continuum.io/archive/Anaconda3-4.3.0-Linux-x86_64.sh
  5. bash Anaconda3-4.3.0-Linux-x86_64.sh -b
  6. cd
  7. vim .bashrc
  8. sudo shutdown -r now
  9. cd downloads/
  10. wget http://files.fast.ai/files/cudnn-8.0-linux-x64-v5.1.tgz
  11. tar -zxf cudnn-8.0-linux-x64-v5.1.tgz
  12. cd cuda/
  13. sudo cp lib64/* /usr/local/cuda/lib64/
  14. sudo cp include/* /usr/local/cuda/include/
  15. pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.1-cp36-cp36m-linux_x86_64.whl
  16. conda install bcolz
  17. conda update --all
  18. pip install git+git://github.com/fchollet/keras.git
  19. echo ‘{
    “image_dim_ordering”: “tf”,
    “epsilon”: 1e-07,
    “floatx”: “float32”,
    “backend”: “tensorflow”
    }’ > ~/.keras/keras.json

Please help!

Thanks,
Naman

Can anybody please tell how to resolve this issue?

Anybody please help!

I ran into the same issue but changing the dim_ordering to data_format helped. Did you make sure to restart the notebook so that the vgg16_agg gets refreshed?

There is a typo in naman’s code above near obtaininput_shape.

I just refreshed the notebook but it didn’t work. Also which version of Keras are you using… By default it installs keras 2.0.8 . If i need to install some other version, please let me know how to install the same too!

Thanks,
Naman