Im trying to load Keras chexNet weight file to Densenet121, https://www.kaggle.com/theewok/chexnet-keras-weights
I'm getting ValueError: You are trying to load a weight file containing 242 layers into a model with 241 layers. if I Call densenet121
densenet = tf.keras.applications.DenseNet121(
include_top=False,
weights="CheXNet_Keras_0.3.0_weights.h5",
input_shape=(224,224,3)
)
If I try:-
densenet = tf.keras.applications.DenseNet121(
include_top=True,
weights="CheXNet_Keras_0.3.0_weights.h5",
input_shape=(224,224,3)
)
I'll get ValueError: Shapes (1024, 1000) and (1024, 14) are incompatible
The answer with popping the last layer does now work anymore, pop only returns the last layer but the model remains unchanged.
I recommend something like this: