To use ResNeXt50, I wrote my code as the API documentation for Keras:


But it reported errors:

AttributeError: module 'keras.applications' has no attribute 'resnext'

That’s weird. The code doesn’t work as documentation said.
So I checked the code of Keras-2.2.4 (the version in my computer), and noticed that this version of code use ‘keras_applications’ instead of ‘keras.applications’.
Then I changed my code:

keras_applications.resnext.ResNeXt50((input_tensor = pinp, include_top = False, weights = 'imagenet')

But it reported another error:

Using TensorFlow backend.
Traceback (most recent call last):
  File "", line 292, in 
  File "", line 277, in main
    model, orig_model, branch_model, head_model = build_model(args)
  File "", line 210, in build_model
    branch_model = resnet_model(args, img_shape)
  File "", line 164, in resnet_model
    base_model = keras_applications.resnext.ResNeXt50(input_tensor = pinp, include_top = False, weights = 'imagenet')
  File "/usr/lib/python3.6/site-packages/keras_applications/", line 555, in ResNeXt50
  File "/usr/lib/python3.6/site-packages/keras_applications/", line 348, in ResNet
AttributeError: 'NoneType' object has no attribute 'image_data_format'

Witout choice, I had to check code of ‘/usr/lib/python3.6/site-packages/keras_applications/’ too. Finally, I realise the ResNeXt50() function need three more arguments:

        input_tensor = pinp, include_top = False, weights = 'imagenet',
        backend = keras.backend, layers = keras.layers, models = keras.models, utils = keras.utils)

Now the program could run ResNeXt50 model correctly. This github issue explained the detail: the ‘keras_applications’ could be used both for Keras and Tensorflow, so it needs to pass library details into model function.