Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
220 views
in Technique[技术] by (71.8m points)

python - Changing weights in the deep learning model from hdf5 to tf

I am running a model on Colab pro.

Getting an error:

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

This is a common problem, which is still not resolved on GitHub.

https://github.com/keras-team/keras/issues/10417

My versions

Tensorflow version 2.4.0

Keras version 2.4.2

My original model works fine, but when I add layers, it fails.

I found the solution here https://github.com/tensorflow/tensorflow/issues/34016

I change the file from hdf5 to tf

weights_path = 'weights'
if not os.path.exists(weights_path):
    os.makedirs(weights_path)
weights_path += '/unet_weights.tf'#.hdf5'

My current output looks like

Epoch 4/100
42/42 - 142s - loss: 0.1752 - val_loss: 0.2444
INFO:tensorflow:Assets written to: weights/unet_weights.tf/assets
Epoch 5/100

Is it a valid approach?

question from:https://stackoverflow.com/questions/65907052/changing-weights-in-the-deep-learning-model-from-hdf5-to-tf

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...