当前位置:网站首页>Solve notimplementederror: layer XX has arguments in`__ init__` and therefore must override `get_ config`
Solve notimplementederror: layer XX has arguments in`__ init__` and therefore must override `get_ config`
2022-06-11 08:07:00 【sinysama】
One 、 Wrong presentation
NotImplementedError: Layer XX has arguments in __init__ and therefore must override get_config.
(XX Represents a custom CLASS)
Two 、 The reason for the error
Use save After the method , Not re started at Class Custom properties in
3、 ... and 、 reason
There are two interfaces for model preservation ,save and save_weights Method .
The difference between the following :
save: Save the structure and parameters of the network model diagram .
save_weights: Save only the parameters of the network model .
If you use save Method , Self defined Class The statement inside requires get_config Reconfigure the declaration , otherwise Tensorflow Unable to save the diagram structure of the model ( As for why , I won't go into it , After all, I use other people's interfaces , Just know this feature ).
If you don't want to rewrite , It can be used save_weights Temporarily solve the problem of saving parameters , There would be no such mistake . But, after all, save() More comprehensive , In order to save trouble in the later period , It is recommended to use it ( Although it takes up a little memory ).
Four 、 Solution
solve save() The specific operation of error reporting is as follows :
In the definition of Class in , increase One get_config Function is used to update the configuration ( The specific operation is as follows ).
among __init__ All properties declared in , Need to be in get_config Function update once . See the picture below Middle part of circle .
get_config The template is as follows , Just replace it and run .
def get_config(self):
config = super().get_config().copy()
config.update({
' attribute 1': self. attribute 1,
' attribute 2': self. attribute 2,
' attribute 3': self. attribute 3,
})
return config

Run again , The model was saved successfully !
边栏推荐
- Typescript enumeration
- Three expressions of integers and their storage in memory
- Training yolov4 CSP model using coco dataset
- Post - payload of interface test
- Typescript configuring ts in koa and using koa router
- TypeScript-null和undefined
- Socket [5] - struct linker usage
- C language to achieve three piece chess (not artificial mental retardation ha ha ha)
- 使用 COCO 数据集训练 YOLOv4-CSP 模型
- JSP technology: JSP overview, JSP basic syntax, JSP instructions, JSP implicit objects, JSP action elements
猜你喜欢

Figure seamless database integration tushare interface

(transformation) tree, binary tree and forest transformation principle

Using Tkinter to realize guessing numbers game

Storage of floating point in memory

Summary of evaluation index knowledge points in target detection: summary of IOU cross overlap unit and map/ap/tp/fp/np

Use of Excel to XML tool of TestLink

Xshell7 and xftp7 to continue using this program, you must apply the latest updates or use a new version

Tidb cloud launched Google cloud marketplace, empowering global developers with a new stack of real-time HTAP databases
![[the most complete ENSP [installation diagram] in history!]](/img/1a/7d50d6e5c06a5e3ce6acab16ddb638.jpg)
[the most complete ENSP [installation diagram] in history!]

C language - growth diary-04- preliminary exploration of local variables (local variables)
随机推荐
Training yolov4 CSP model using coco dataset
Remote office experience sharing | community essay solicitation
How to start participating in the open source community
彻底记住ImageView的background和src的区别
Typescript configuring ts in koa and using koa router
C language - Growth Diary -03- function definition and function prototype declaration
Space geometry
放大镜子效果图
空间几何
Typescript interface and type alias similarities and differences
Shell编程笔记
Summary of knowledge points of customized ViewGroup - continuously updated
Sort - Swap sort
C. Manipulating History(贪心/哈希/思维/好题)
用 Keras/TensorFlow 2.9 创建深度学习模型的方法总结
图数据库无缝集成Tushare接口
如何开始参与开源社区
Servlet
Layout of code setting constraintlayout_ constraintDimensionRatio
Alchemy experience (model training of deep learning) the necessity of timely adjusting training parameters for some situations (the adjustment of learning rate LR is the primary) summarizes some metho