我试图保存 keras 完整模型,但遇到了这个错误
Traceback (most recent call last):
File "d:/Workspace/College/Semester 8/Tugas Akhir/Keras-RFCN-master/Keras-RFCN-master/testing.py", line 133, in <module>
main()
File "d:/Workspace/College/Semester 8/Tugas Akhir/Keras-RFCN-master/Keras-RFCN-master/testing.py", line 96, in main
model.save("D:/weight.h5")
File "d:\Workspace\College\Semester 8\Tugas Akhir\Keras-RFCN-master\Keras-RFCN-master\KerasRFCN\Model\Model.py", line 560, in save
self.model.save(save_path)
File "C:\Users\kevin\anaconda3\envs\tf-gpu\lib\site-packages\keras\engine\network.py", line 1139, in save
save_model(self, filepath, overwrite, include_optimizer)
File "C:\Users\kevin\anaconda3\envs\tf-gpu\lib\site-packages\keras\engine\saving.py", line 415, in save_wrapper
save_function(obj, filepath, overwrite, *args, **kwargs)
File "C:\Users\kevin\anaconda3\envs\tf-gpu\lib\site-packages\keras\engine\saving.py", line 507, in save_model
_serialize_model(model, h5dict, include_optimizer)
File "C:\Users\kevin\anaconda3\envs\tf-gpu\lib\site-packages\keras\engine\saving.py", line 101, in _serialize_model
model_config = json.dumps(model_config, default=get_json_type)
File "C:\Users\kevin\anaconda3\envs\tf-gpu\lib\json\__init__.py", line 238, in dumps
**kw).encode(obj)
File "C:\Users\kevin\anaconda3\envs\tf-gpu\lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "C:\Users\kevin\anaconda3\envs\tf-gpu\lib\json\encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "C:\Users\kevin\anaconda3\envs\tf-gpu\lib\site-packages\keras\engine\saving.py", line 91, in get_json_type
raise TypeError('Not JSON Serializable: %s' % (obj,))
TypeError: Not JSON Serializable: <KerasRFCN.Config.Config object at 0x0000029B0A3BD248>
通过该错误,很明显 JSON 无法序列化我的类,该类返回一个名为 config 的对象。那么如何确保 Keras 可以序列化我的配置..??
我认为在init中定义的所有定义都可以序列化。
我真的是 python、Keras 和 TensorFlow 的新手。
哔哔one
相关分类