Hello Everyone,

I want to use Pre-trained models such as Xception, VGG16, ResNet50, etc for my Deep Learning image recognition project to quick train the model on training set with high accuracy. I am having trouble to find exact code to implement my model. I tried to fit the model with the following code with modifications in output layer. I am getting these errors after running on the Jupyter Notebook.

ValueError: Error when checking input: expected image_input to have 4 dimensions, but got array with shape (224, 224, 3)

ValueError: The shape of the input to "Flatten" is not fully defined (got (None, None, 512). Make sure to pass a complete "input_shape"

ValueError : Error when checking target (output shape error)

Dimensional errrors

Can any one please help to find the right codes? Thank you so much for help in advance :)

  • Initially Input images are of size (256,256,3)
  • I am using keras framework
  • My model codes are bellow

batch_size = 32

epochs = 50

smooth = 1

print('Build model...')

model = Sequential()

model.add(VGG16(1, weights = 'imagenet', input_shape=train_X.shape[1:]))

model.compile(loss='binary_crossentropy', metrics=[dice_coef],

optimizer='adam',

class_mode="sigmoid")

model.summary()

# fit model on train_data

print("\nTraining...")

model.fit(img, mask,batch_size=16,epochs=epochs)

More Saket Chaturvedi's questions See All
Similar questions and discussions