Skip to content
This repository was archived by the owner on Nov 3, 2022. It is now read-only.
This repository was archived by the owner on Nov 3, 2022. It is now read-only.

NASNetLarge input shape error #208

Open
@buckeye17

Description

@buckeye17

Summary

I'm able to fit several Keras applications (VGG16, InceptionResNetV2, Xception, etc) without error, but when I attempt to fit NASNetLarge with the line of code shown below, I get the error message shown below. Clearly the error message isn't true based on my line of code since I have include_top=False. In fitting these different applications, I'm simply importing the corresponding function and renaming the function in my line of code given below.

Environment

  • Python version: 3.8.12
  • Keras version: 2.7.0
  • Keras-applications version: 2.7.0
  • Keras backend with version: tensorflow-gpu 2.7.0

Logs or source codes for reproduction

base_model = NASNetLarge(classes=n_classes, include_top=False, input_shape=(img_height, img_width, 3), weights='imagenet')

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_51428/1637328170.py in <module>
      2 # base_model = VGG19(classes=n_classes, include_top=False, input_shape=(img_height, img_width, 3), weights='imagenet')
      3 # base_model = InceptionResNetV2(classes=n_classes, include_top=False, input_shape=(img_height, img_width, 3), weights='imagenet')
----> 4 base_model = NASNetLarge(classes=n_classes, include_top=False, input_shape=(img_height, img_width, 3), weights='imagenet')
      5 
      6 # from tensorflow.keras.applications.inception_resnet_v2 import InceptionResNetV2

~\Anaconda3\envs\deep_learning\lib\site-packages\keras\applications\nasnet.py in NASNetLarge(input_shape, include_top, weights, input_tensor, pooling, classes)
    461           backend that does not support separable convolutions.
    462   """
--> 463   return NASNet(
    464       input_shape,
    465       penultimate_filters=4032,

~\Anaconda3\envs\deep_learning\lib\site-packages\keras\applications\nasnet.py in NASNet(input_shape, penultimate_filters, num_blocks, stem_block_filters, skip_reduction, filter_multiplier, include_top, weights, input_tensor, pooling, classes, default_size, classifier_activation)
    172 
    173   # Determine proper input shape and default size.
--> 174   input_shape = imagenet_utils.obtain_input_shape(
    175       input_shape,
    176       default_size=default_size,

~\Anaconda3\envs\deep_learning\lib\site-packages\keras\applications\imagenet_utils.py in obtain_input_shape(input_shape, default_size, min_size, data_format, require_flatten, weights)
    347     if input_shape is not None:
    348       if input_shape != default_shape:
--> 349         raise ValueError('When setting `include_top=True` '
    350                          'and loading `imagenet` weights, '
    351                          f'`input_shape` should be {default_shape}.  '

ValueError: When setting `include_top=True` and loading `imagenet` weights, `input_shape` should be (331, 331, 3).  Received: input_shape=(256, 256, 3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions