I'm trying to use the Keras ResNet50 implementation for training a binary image classification model.
I want to test the model without using transfer learning but when i try to change the output layer using a simple dense layer with sigmoid activation for the binary classification i got errors regarding shape size.
My code is this:
baseModel= ResNet50(weights=None, include_top=False, classes=2, pooling=max)
output = baseModel.output
output = layers.Dense(1, activation='sigmoid')(output)
model = keras.models.Model(inputs=baseModel.input, outputs=output)
model.compile(optimizer=Adam(learning_rate=0.0001), loss='binary_crossentropy', metrics=['accuracy'])
Doing this i got this error:
ValueError: logits and labels must have the same shape ((None, 7, 7, 1) vs (None, 1))
If i add a flatten layer before the dense layer i got:
ValueError: The last dimension of the inputs to `Dense` should be defined. Found `None`.
What I'm missing here? How i can change the imput shape for the dense layer?
ResNet50(weights=None, include_top=True, classes=1)
? – jakub