Relative Content

Tag Archive for pythonkerasdeep-learningtransfer-learning

Layer count mismatch when loading weights from file transfer learning in keras

I’m new to convolutional neural network and machine learning in general, so sorry in advance if my question is really straighforward, but I have searched for a while without getting a solution to fix it. For a semantic segmentation task, I am pre-training a U-Net model of 4 convolution blocks in keras with a dataset whose patches have input_shape = (128,128,3). Then, I need to train this same model, but with a new dataset (input_shape=(128,128,5)). So far, I think I’ve managed to apply the convolution necessary for the U-Net model to accept tensors from 5 channels. I’ve saved the model with the weights in an h5 file. However, I got the error “keras load_weights() ValueError: Layer count mismatch when loading weights from file. Model expected 4 layers, found 23 saved layers” at the line indicate in bold in my second code block.