CheXNet-Keras icon indicating copy to clipboard operation
CheXNet-Keras copied to clipboard

Problem with ModelFactory class while loading ChexNet-keras.h5 pretrained file

Open WrathofBhuvan11 opened this issue 4 years ago • 1 comments

ValueError: You are trying to load a weight file containing 242 layers into a model with 241 layers.

WrathofBhuvan11 avatar Oct 19 '20 17:10 WrathofBhuvan11

You need to load model weights after adding one Dense layer. Try this -

densenet = tf.keras.applications.DenseNet121( include_top=False, weights=None, pooling='max',input_shape=(128,128,3) ) input_shape = (128,128,3) x = densenet.output predictions = Dense(16, activation="sigmoid", name="predictions")(x) model = tf.keras.Model(inputs=densenet.inputs, outputs=predictions) model.load_weights(weights_path,by_name=True, skip_mismatch=True)

nitishkmr005 avatar Nov 29 '20 18:11 nitishkmr005