admin管理员组文章数量:1130349
完整报错如下:
Traceback (most recent call last):
File "/ad_ctr/new_thought/tmp4.py", line 459, in <module>
model.save(save_path.format('FCINN', 'FCINN-11-13.h5'))
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/network.py", line 1052, in save
signatures, options)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/saving/save.py", line 128, in save_model
'Saving the model to HDF5 format requires the model to be a '
NotImplementedError: Saving the model to HDF5 format requires the model to be a Functional model or a Sequential model. It does not work for subclassed models, because such models are defined via the body of a Python method, which isn't safely serializable. Consider saving to the Tensorflow SavedModel format (by setting save_format="tf") or using `save_weights`.
原因:自定义Keras的类是不能保存成.h5格式的,可以保存权重或者save_format="tf"
from tensorflow.keras.models import save_model, load_model
# model.save(save_path.format('FCINN', 'test_FCINN-11-13.h5'))
model.save(save_path.format('FCINN', 'test_FCINN-11-13_serving'), save_format="tf")
# model = load_model(save_path.format('FCINN', 'test_FCINN-11-13.h5'))
model = load_model(save_path.format('FCINN', 'test_FCINN-11-13_serving'))
参考:
https://my.oschina/u/4396881/blog/3375667
https://wwwblogs/Manuel/p/13357212.html
tf.saved_model.save方式:
https://cloud.tencent/developer/article/1785139
完整报错如下:
Traceback (most recent call last):
File "/ad_ctr/new_thought/tmp4.py", line 459, in <module>
model.save(save_path.format('FCINN', 'FCINN-11-13.h5'))
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/network.py", line 1052, in save
signatures, options)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/saving/save.py", line 128, in save_model
'Saving the model to HDF5 format requires the model to be a '
NotImplementedError: Saving the model to HDF5 format requires the model to be a Functional model or a Sequential model. It does not work for subclassed models, because such models are defined via the body of a Python method, which isn't safely serializable. Consider saving to the Tensorflow SavedModel format (by setting save_format="tf") or using `save_weights`.
原因:自定义Keras的类是不能保存成.h5格式的,可以保存权重或者save_format="tf"
from tensorflow.keras.models import save_model, load_model
# model.save(save_path.format('FCINN', 'test_FCINN-11-13.h5'))
model.save(save_path.format('FCINN', 'test_FCINN-11-13_serving'), save_format="tf")
# model = load_model(save_path.format('FCINN', 'test_FCINN-11-13.h5'))
model = load_model(save_path.format('FCINN', 'test_FCINN-11-13_serving'))
参考:
https://my.oschina/u/4396881/blog/3375667
https://wwwblogs/Manuel/p/13357212.html
tf.saved_model.save方式:
https://cloud.tencent/developer/article/1785139
本文标签: SavedModelformatsavingTensorFlowTF
版权声明:本文标题:Consider saving to the Tensorflow SavedModel format (by setting save_format=“tf“) or using `save_wei 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/jiaocheng/1754466465a2690235.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论