0
votes

I am a beginner to transfer learning, In this project i aimed to use VGG16 and add some more layers to do a classification between 2 classes: class0 and class1

I have dataframe named 'train' with 'id' column contains file names while label contains class of that image

Images and prepared through ImageDataGenerator() and flow.from_dataframe

To summarise, the last layer of mine was Dense(2,activation='softmax')

The input image to VGG16 has shape of (32,32,3)

However, it kepts being error:

ValueError: Error when checking target: expected dense_55 to have 2 dimensions, but got array with shape (1, 32, 32, 3)

A summary of my model:

Here was my jupyter notebook for training.

what is wrong with my coding here?

1

1 Answers

0
votes

The error means that your network's output has two dimensions (as the summary shows, output shape is (None, 2)), but your label has shape (1, 32, 32, 3).

In your validation data generation, you set class_mode="input". This means that your labels will also be images of the same shape as your input (see doc https://keras.io/preprocessing/image/#flow_from_dataframe) instead of being 2 dimensional classification labels. This is the problem. Use class_mode="categorical" as you used for the training data.