Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model.save() 保存模型时报错 #507

Open
dashilu1573 opened this issue Mar 1, 2023 · 1 comment
Open

model.save() 保存模型时报错 #507

dashilu1573 opened this issue Mar 1, 2023 · 1 comment

Comments

@dashilu1573
Copy link

dashilu1573 commented Mar 1, 2023

model.save() 保存SavedModel时,报错:

Traceback (most recent call last):
File "/Users/luyafei/Downloads/code/DeepTextMatch/SBERT/run.py", line 142, in
model.fit(train_generator.forfit(),
File "/Users/luyafei/opt/anaconda3/envs/py3-tf2-new/lib/python3.9/site-packages/keras/utils/traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/Users/luyafei/opt/anaconda3/envs/py3-tf2-new/lib/python3.9/site-packages/keras/layers/serialization.py", line 117, in populate_deserializable_objects
LOCAL.ALL_OBJECTS['Functional'] = models.Functional
AttributeError: module 'keras.api._v2.keras.models' has no attribute 'Functional'

提问时请尽可能提供如下信息:

基本信息

  • 你使用的操作系统: mac linux下都尝试不行
  • 你使用的Python版本: 3.9
  • 你使用的Tensorflow版本: tf2.9.0
  • 你使用的Keras版本: 2.9.0
  • 你使用的bert4keras版本: v0.11.1
  • 你使用纯keras还是tf.keras: tf.keras
  • 你加载的预训练模型: chinese_wwm_ext_L-12_H-768_A-12

核心代码

        # 6. model fit
        model.fit(train_generator.forfit(),
                  steps_per_epoch=len(train_generator),
                  epochs=epochs,
                  callbacks=[earlystop, checkpoint])

        model.save("../output/savedmodel/")  # SavedModel 格式

输出信息

# 请在此处贴上你的调试输出

自我尝试

不管什么问题,请先尝试自行解决,“万般努力”之下仍然无法解决再来提问。此处请贴上你的努力过程。

@dashilu1573 dashilu1573 changed the title model.save() 保存模型时 model.save() 保存模型时报错 Mar 1, 2023
@bojone
Copy link
Owner

bojone commented Mar 24, 2023

这么新的tf和keras我无能为力啊,抱歉。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants