-1

this was the error:

ValueError                                Traceback (most recent call last)
<ipython-input-56-84713bdbff2f> in <module>()
     57 
     58 
---> 59 base_model = tf.keras.applications.vgg16.VGG16(weights = 'imagenet', include_top = False, input_shape = (-1,100,100))
     60 for layer in base_model.layers:
     61   layer.trainable = False

1 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/applications/imagenet_utils.py in obtain_input_shape(input_shape, default_size, min_size, data_format, require_flatten, weights)
    364         if input_shape[-1] != 3 and weights == 'imagenet':
    365           raise ValueError('The input must have 3 channels; got '
--> 366                            '`input_shape=' + str(input_shape) + '`')
    367         if ((input_shape[0] is not None and input_shape[0] < min_size) or
    368             (input_shape[1] is not None and input_shape[1] < min_size)):

ValueError: The input must have 3 channels; got `input_shape=(-1, 100, 100)`
Ivan
  • 34,531
  • 8
  • 55
  • 100
  • error when i try to do (-1,100,100,3) – areeb adnan Jul 27 '21 at 18:24
  • ValueError Traceback (most recent call last) in () 43 y = np.array(y) 44 ---> 45 x = x.reshape(-1,100,100,3) 46 47 ValueError: cannot reshape array of size 92200000 into shape (100,100,3) – areeb adnan Jul 27 '21 at 18:24
  • I'm affraid I can't help you, you are using tensorflow. Removing [tag:pytorch] tag. – Ivan Jul 27 '21 at 20:17

2 Answers2

2

According to docs argument input_shape should be

optional shape tuple, only to be specified if include_top is False (otherwise the input shape has to be (224, 224, 3) (with channels_last data format) or (3, 224, 224) (with channels_first data format). It should have exactly 3 input channels, and width and height should be no smaller than 32. E.g. (200, 200, 3) would be one valid value.

so using input_shape=(100, 100, 3) should fix the issue

Dominik Ficek
  • 544
  • 5
  • 18
0

You need to create an array with three channels to feed it to your pretrained model.

x = np.repeat(x[..., np.newaxis], 3, -1)