将深度学习模型中的权重从 hdf5 更改为 tf

时间:2021-01-26 18:22:37

标签: python tensorflow keras deep-learning

我正在 Colab pro 上运行模型。

出现错误:

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

这是一个常见问题,GitHub 上仍未解决。

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

我的版本

Tensorflow version 2.4.0

Keras version 2.4.2

我的原始模型工作正常,但是当我添加图层时,它失败了。

我在这里找到了解决方案https://github.com/tensorflow/tensorflow/issues/34016

我将文件从 hdf5 更改为 tf

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

我当前的输出看起来像

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

这是一种有效的方法吗?

0 个答案:

没有答案
相关问题