keras-team/keras-applications

ValueError: The last dimension of the inputs to `Dense` should be defined. Found `None`.

zubairahmed-ai opened this issue · 2 comments

Summary

Receiving this error trying to Fine-tune a EfficientNetB0 using Tensorflow 2.0

Environment

  • Python version: 3.6.4
  • Keras version: 2.3.1
  • Keras-applications version:1.0.8
  • Keras backend with version:

Logs or source codes for reproduction

ValueError: The last dimension of the inputs to Denseshould be defined. FoundNone.

When fine-tuning a EfficientNetB0 with my own fully connected layer I get the above error

my import looks like this import efficientnet.tfkeras as efn

and

baseModel = efn.EfficientNetB0(weights="imagenet", include_top=False)
headModel = FCHeadNet.build(baseModel, len(classNames), 256)

But the error is shown in this line

headModel = Dense(D, activation="relu")(headModel)

How did you fixed it?