
处理Tensorflow2.0中tf.keras.Model.load_weights()的错误问题
5星
- 浏览量: 0
- 大小:None
- 文件类型:None
简介:
本文介绍了解决在使用TensorFlow 2.0时遇到的tf.keras.Model.load_weights()函数错误的方法和技巧。
错误描述:1. 保存模型:`model.save_weights(./model.h5)`
2. 脚本重启。
3. 加载模型:`model.load_weights(./model.h5)`
4. 模型报错:ValueError: You are trying to load a weight file containing 12 layers into a model with 0 layers。
问题分析:在尝试加载权重文件之前,创建的模型尚未编译。通常情况下,在加载模型前需要调用 `model.build(input_shape)` 来指定输入形状。然而,由于我的数据集已经将输入转换为字典格式,目前还没有找到如何在这种场景下匹配 `input_shape` 的方法。
全部评论 (0)
还没有任何评论哟~


