最近在做一个人脸识别的项目,但是在保存模型的过程中出现了一个报错,网上查找也没有得到答案,记录一下,等解决了再来补充,报错信息如下TypeError: __init__() missing 2 required positional arguments: 'filters' and 'kernel_size'
File "C:\Users\dell\Desktop\2023\python\人脸识别\face_recognition_web\face_dect2\face_train.py", line 181, in load_model
self.model = load_model(file_path)
File "C:\Users\dell\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
File "C:\Users\dell\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\dtensor\utils.py", line 95, in _wrap_function
init_method(layer_instance, *args, **kwargs)
TypeError: __init__() missing 2 required positional arguments: 'filters' and 'kernel_size'
找了一圈发现没有这个报错了,新的报错是'NoneType' object has no attribute 'shape'
通过查找发现是中文路径的问题,猜想之前可能是因为这个地方出错影响到上面的报错了,反正最后就是跑通了。。。。。。
新的报错又又又又来了,module 'keras.backend' has no attribute 'image_dim_ordering'
通过一言不合就摆渡的方法,找打需要将将
K.image_dim_ordering() == "th" 代码改为
K.image_data_format() == "channels_first"
补充:
K.image_data_format() == 'channel_last'
K.image_data_format() == 'channel_first'
替换
K.image_dim_ordering() == 'tf'
K.image_dim_ordering() == 'th'
新的报错TypeError: ('Keyword argument not understood:', 'border_mode')
还是keras版本的问题,需要将border_mode改为padding
Exception encountered when calling layer "conv2d_3" (type Conv2D).
新的报错AttributeError: 'Sequential' object has no attribute 'predict_proba'
解决方法详见keras官方文档
简单来说就是用predict代替predict_proba,但是对于下面的predict_classes很复杂,