Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

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

Open
WrathofBhuvan11 opened this issue Oct 19, 2020 · 1 comment

Comments

@WrathofBhuvan11
Copy link

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

@nitishkmr005
Copy link

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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants