首页 Paddle框架 帖子详情
将Accuracy()换成Recall()就报错
收藏
快速回复
Paddle框架 问答深度学习模型训练 813 5
将Accuracy()换成Recall()就报错
收藏
快速回复
Paddle框架 问答深度学习模型训练 813 5

我在项目库找了一个DCANet的项目想学习一下,在成功运行源代码后我想尝试修改一些参数,我想做的第一个修改是把paddle.metric.Accuracy() 换成Recall()、Auc()等评估指标,如下图:

报错如下:

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/utils.py:26: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
def convert_to_list(value, n, name, dtype=np.int):
W0607 16:50:23.921407 8942 device_context.cc:362] Please NOTE: device: 0, GPU Compute Capability: 7.0, Driver API Version: 10.1, Runtime API Version: 10.1
W0607 16:50:23.926188 8942 device_context.cc:372] device: 0, cuDNN Version: 7.6.
The loss value printed in the log is the current step, and the metric is the average value of previous step.
Epoch 1/50
Traceback (most recent call last):
File "code/train.py", line 130, in
verbose=1
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/hapi/model.py", line 1495, in fit
logs = self._run_one_epoch(train_loader, cbks, 'train')
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/hapi/model.py", line 1802, in _run_one_epoch
data[len(self._inputs):])
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/hapi/model.py", line 941, in train_batch
loss = self._adapter.train_batch(inputs, labels)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/hapi/model.py", line 669, in train_batch
m = metric.update(* [to_numpy(m) for m in to_list(metric_outs)])
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/metric/metrics.py", line 716, in update
self._stat_pos[bin_idx] += 1.0
IndexError: index -5367 is out of bounds for axis 0 with size 4096
terminate called without an active exception


--------------------------------------
C++ Traceback (most recent call last):
--------------------------------------
0 paddle::framework::SignalHandle(char const*, int)
1 paddle::platform::GetCurrentTraceBackString[abi:cxx11]()

----------------------
Error Message Summary:
----------------------
FatalError: `Process abort signal` is detected by the operating system.
[TimeInfo: *** Aborted at 1623055831 (unix time) try "date -d @1623055831" if you are using GNU date ***]
[SignalInfo: *** SIGABRT (@0x3e8000022ee) received by PID 8942 (TID 0x7f5daaa6f700) from PID 8942 ***]

Aborted (core dumped)

 


我看这个报错信息看不出来是啥问题?我查PaddlePaddle的API,这几个应该都是可以的,不知道是什么原因报错呢?

麻烦各位高手指点,谢谢!

0
收藏
回复
全部评论(5)
时间顺序
TC.Long
#2 回复于2021-06

Accuracy 是支持多分类的,但是Recall 和 Auc目前都只支持二分类,所以替换后可能会有问题~

0
回复
大连之星snort
#3 回复于2021-12

楼上说的正确,我也是看了官方API说明才发现recall仅支持两分类,不知道为啥。

0
回复
DeepGeGe
#4 回复于2021-12

是的呀,因为recall和precision就是针对每一类来的。每一类有其精确率和召回率。

0
回复
DeepGeGe
#5 回复于2021-12

仔细想想也不对。。。

不过报错是报的IndexError: index -5367 is out of bounds for axis 0 with size 4096。

0
回复
莫名其妙的简
#6 回复于2023-07
仔细想想也不对。。。 不过报错是报的IndexError: index -5367 is out of bounds for axis 0 with size 4096。

卡在这块了,真的服了,不知道怎么解决

0
回复
需求/bug反馈?一键提issue告诉我们
发现bug?如果您知道修复办法,欢迎提pr直接参与建设飞桨~
在@后输入用户全名并按空格结束,可艾特全站任一用户