Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paddle.vision.ops.yolo_loss返回值和文档描述完全不同 #40145

Closed
phoenixsfly opened this issue Mar 3, 2022 · 2 comments · Fixed by #40185
Closed

paddle.vision.ops.yolo_loss返回值和文档描述完全不同 #40145

phoenixsfly opened this issue Mar 3, 2022 · 2 comments · Fixed by #40185
Assignees

Comments

@phoenixsfly
Copy link

phoenixsfly commented Mar 3, 2022

  • 版本、环境信息:
       1)PaddlePaddle版本:2.2

这是
paddle.vision.ops.yolo_loss函数的文档链接,该函数运算通过给定的预测结果和真实框计算yolov3损失。

返回值:
Tensor, yolov3损失的值,具有形状[N]的1-D Tensor。

这是文档的代码示例:

import paddle
import numpy as np

x = np.random.random([2, 14, 8, 8]).astype('float32')
gt_box = np.random.random([2, 10, 4]).astype('float32')
gt_label = np.random.random([2, 10]).astype('int32')

x = paddle.to_tensor(x)
gt_box = paddle.to_tensor(gt_box)
gt_label = paddle.to_tensor(gt_label)

loss = paddle.vision.ops.yolo_loss(x,
                                   gt_box=gt_box,
                                   gt_label=gt_label,
                                   anchors=[10, 13, 16, 30],
                                   anchor_mask=[0, 1],
                                   class_num=2,
                                   ignore_thresh=0.7,
                                   downsample_ratio=8,
                                   use_label_smooth=True,
                                   scale_x_y=1.)

直接运行的结果:

(Tensor(shape=[2], dtype=float32, place=CPUPlace, stop_gradient=True,
        [175.69551086, 196.61924744]),
 Tensor(shape=[2, 2, 8, 8], dtype=float32, place=CPUPlace, stop_gradient=True,
        [[[[0., 1., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0.]],
 
          [[0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 1., 0., 0.],
           [0., 0., 1., 0., 1., 0., 1., 0.],
           [0., 1., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 1., 1., 0.],
           [0., 1., 0., 0., 0., 0., 0., 0.],
           [1., 0., 0., 0., 0., 0., 0., 0.]]],
 
 
         [[[0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 1., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 1., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0.]],
 
          [[0., 0., 0., 1., 0., 0., 0., 1.],
           [0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 1., 1.],
           [0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 1., 0., 0., 0., 0.],
           [0., 1., 0., 0., 0., 0., 1., 0.],
           [0., 0., 0., 1., 0., 0., 0., 0.]]]]),
 Tensor(shape=[2, 10], dtype=int32, place=CPUPlace, stop_gradient=True,
        [[1, 1, 1, 0, 1, 1, 1, 1, 1, 1],
         [1, 1, 1, 0, 1, 1, 1, 0, 1, 1]]))

我猜测是文档有问题,返回的是一个元组,该元组的第一个元素是损失函数值。
但问题是元素后几个元素代表什么意思呢?

@paddle-bot-old
Copy link

paddle-bot-old bot commented Mar 3, 2022

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档常见问题历史IssueAI社区来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

@yghstill
Copy link
Contributor

yghstill commented Mar 4, 2022

@phoenixsfly 根据源码,计算结果返回三个Tensor:https://github.com/PaddlePaddle/Paddle/blob/release/2.2/python/paddle/vision/ops.py#L243-L247

感谢指正,我们修复下文档

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants