karthikeyan
karthikeyan

Reputation: 235

ValueError: ('Error when checking model input: expected no data, but got:', array)

I'm trying to build an inception and resnet model with my own image data. The dataset is 8000 images in total and has 6 labels. Everything goes fine while building the model. But the mentioned error occurs in the model.fit(). I'm really not sure what the problem after spending 14 hours.

I tried the following

  1. Changing the image dimension ordering

  2. Making changes to keras.json

  3. changing the input_tensor shape in the model

Image of the error : enter image description here

inception_model = InceptionV3(input_tensor = inception_model.input, include_top = True, weights = 'imagenet')
inception_last_layer = inception_model.get_layer('predictions').output
inception_out = Dense(num_classes, activation='softmax', name='output')(inception_last_layer)
custom_inception = Model(inception_model.input, inception_out)

for layer in custom_inception.layers[:-3]:
        layer.trainable = False

custom_inception.compile(loss='categorical_crossentropy',optimizer='adam',metrics=['accuracy', 'mse', 'mae', 'mape'])
train_inception = custom_inception.fit(X_train, y_train, batch_size=8, epochs=2)

EDIT: I'm currently using keras 2.2.0 which I downgraded from latest version after going through some keras issues in github. It did solve some initial hiccups. I'm currently using inception and resnet from their respective python files which I made some changes include_top=include_top to require_flatten=include_top from this

EDIT2: Here are the inputs shapes

(1690, 220, 220, 1)  is the X_train shape
(1690, 6)  is the y_train 
(423, 220, 220, 1)  is the X_test shape
(423, 6)  is the y_test 

Upvotes: 3

Views: 1649

Answers (1)

karthikeyan
karthikeyan

Reputation: 235

Solved this problem by the following steps:

input_tensor=Input((300,300,3))

in place of

input_tensor = inception_model.input
  1. Upgrading tensorflow and keras to 1.13.1 and 2.2.4
  2. Defining the model with input shape(300,300,3) and stacking my (300,300,1) input thrice on channel axis inorder to match (300,300,3)

Upvotes: 1

Related Questions