当前位置: 代码迷 >> 综合 >> 车牌识别,部分错误C++ Call Stacks (More useful to developers):Error Message Summary:
  详细解决方案

车牌识别,部分错误C++ Call Stacks (More useful to developers):Error Message Summary:

热度:90   发布时间:2024-02-11 06:30:51.0

《百度顶会论文复现营》其中作业《车牌识别》部分,运行代码出现错误。
解决方法和原因,在错误信息下面
定义DNN网络如下错误信息如下:

train_pass:0,batch_id:50,train_loss[0.28051484],train_acc:[1.]
train_pass:0,batch_id:100,train_loss[1.2990379],train_acc:[1.]
train_pass:0,batch_id:150,train_loss[0.5766834],train_acc:[1.]
train_pass:0,batch_id:200,train_loss[0.04432668],train_acc:[1.]
train_pass:0,batch_id:250,train_loss[2.531902],train_acc:[0.]
train_pass:0,batch_id:300,train_loss[0.03859062],train_acc:[1.]
train_pass:0,batch_id:350,train_loss[1.3039756],train_acc:[1.]
train_pass:0,batch_id:400,train_loss[0.09336647],train_acc:[1.]
---------------------------------------------------------------------------EnforceNotMet                             Traceback (most recent call last)<ipython-input-6-77c28d4d8993> in <module>10             labels = np.array([x[1] for x in data]).astype('int64')11             labels = labels[:,np.newaxis]
---> 12             image = fluid.dygraph.to_variable(images)13             label = fluid.dygraph.to_variable(labels)14 
</opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/decorator.py:decorator-gen-153> in to_variable(value, name, zero_copy)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/wrapped_decorator.py in __impl__(func, *args, **kwargs)23     def __impl__(func, *args, **kwargs):24         wrapped_func = decorator_func(func)
---> 25         return wrapped_func(*args, **kwargs)26 27     return __impl__
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/framework.py in __impl__(*args, **kwargs)214         assert in_dygraph_mode(215         ), "We Only support %s in imperative mode, please use fluid.dygraph.guard() as context to run it in imperative Mode" % func.__name__
--> 216         return func(*args, **kwargs)217 218     return __impl__
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/base.py in to_variable(value, name, zero_copy)565                 persistable=False,566                 zero_copy=zero_copy,
--> 567                 name=name if name else '')568             return py_var569     elif isinstance(value, (core.VarBase, framework.Variable,
EnforceNotMet: --------------------------------------------
C++ Call Stacks (More useful to developers):
--------------------------------------------
0   std::string paddle::platform::GetTraceBackString<char const*>(char const*&&, char const*, int)
1   paddle::platform::EnforceNotMet::EnforceNotMet(std::__exception_ptr::exception_ptr, char const*, int)
2   paddle::platform::GpuMemcpySync(void*, void const*, unsigned long, cudaMemcpyKind)----------------------
Error Message Summary:
----------------------
ExternalError:  Cuda error(4), unspecified launch failure.[Advise: An exception occurred on the device while executing a kernel. Common causes include dereferencing an invalid device pointerand accessing out of bounds shared memory. The device cannot be used until cudaThreadExit() is called. All existing device memory allocations are invalid and must be reconstructed if the program is to continue usingCUDA.] at (/paddle/paddle/fluid/platform/gpu_info.cc:281)

值得说明的是:此问题不一定只出现在车牌识别案例中

原因:首先,车牌识别的样本标签共计65个,但是要注意我们的运行环境是在百度AI Studio下运行,出现此问题说明结果越界(比较像数组超出长度),
在定义DNN网络结构时:self.hidden4 = Linear(100,65,act=‘softmax’)
65代表输出结果的标签数是65,但是实际上标签的个数是66个Why?
注意我们的运行环境是在百度AI Studio下运行,车牌数据集在解压之后会出现两个无用文件夹,一是_MacOS文件夹通常在生成训练列表时会被删除,二是一个隐藏文件夹.ipynb_checkpoints,生成标签文件时,会将它统计其中,导致标签数由65变为66
解决方法:self.hidden4 = Linear(100,65,act=‘softmax’)改为self.hidden4 = Linear(100,66,act=‘softmax’)
也就是65改成66

  相关解决方案