保存用 Keras 包裹的模型

编程入门 行业动态 更新时间:2024-10-28 12:21:43
本文介绍了保存用 Keras 包裹的模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

对不起,我的幼稚问题,但我正在尝试保存我的 keras 模型 (),其中我使用 TFBertModel() 函数作为隐藏层.为此,我使用了 tf.keras 包提供的 save() 函数.

Sorry for my naive question but I am trying to save my keras model () in which I use TFBertModel() function as an hidden layer. To do that I use the save() function provided by the tf.keras package.

但是我收到了这个错误:

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: 

该错误可以从我的 colab 中重现:https://colab.research.google/drive/18HYwffkXCylPqeA-8raL82vfwOjb-aLP

The error can be reproduce from my colab : https://colab.research.google/drive/18HYwffkXCylPqeA-8raL82vfwOjb-aLP

另一个问题是我应该如何调用这个模型进行预测?

And another question is how should I call this model for prediction ?

感谢您的帮助!

推荐答案

没有看到代码无法真正回答你,但你应该看看这里:

Can't really answer you without seeing the code, but you should probably look here:

https:///towardsdatascience/text-classification-with-hugging-face-transformers-in-tensorflow-2-without-tears-ee50e4f3e7ed

这篇关于保存用 Keras 包裹的模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 00:46:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1401823.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:包裹   模型   Keras

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!