简体   繁体   English

保存用 Keras 包裹的模型

[英]Save model wrapped in Keras

Sorry for my naive question but I am trying to save my keras model () in which I use TFBertModel() function as an hidden layer.抱歉我的幼稚问题,但我正在尝试保存我的 keras 模型 (),其中我使用 TFBertModel() 函数作为隐藏层。 To do that I use the save() function provided by the tf.keras package.为此,我使用了 tf.keras 包提供的 save() 函数。

But I got this error:但我收到了这个错误:

---------------------------------------------------------------------------

NotImplementedError                       Traceback (most recent call last)

<ipython-input-13-3b315f7219da> in <module>()
----> 1 model.save('model_weights.h5')

8 frames

/tensorflow-2.1.0/python3.6/tensorflow_core/python/keras/engine/network.py in get_config(self)
    915   def get_config(self):
    916     if not self._is_graph_network:
--> 917       raise NotImplementedError
    918     return copy.deepcopy(get_network_config(self))
    919 

NotImplementedError: 

The error can be reproduce from my colab : https://colab.research.google.com/drive/18HYwffkXCylPqeA-8raL82vfwOjb-aLP该错误可以从我的 colab 中重现: https ://colab.research.google.com/drive/18HYwffkXCylPqeA-8raL82vfwOjb-aLP

And another question is how should I call this model for prediction ?另一个问题是我应该如何调用这个模型进行预测?

Thx for your help!谢谢你的帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM