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

关于使用array来索引tensor #33605

Closed
geoyee opened this issue Jun 16, 2021 · 9 comments
Closed

关于使用array来索引tensor #33605

geoyee opened this issue Jun 16, 2021 · 9 comments
Assignees

Comments

@geoyee
Copy link

geoyee commented Jun 16, 2021

这是UCN的pytorch版本,x和y是特征点的坐标,源码就是这样索引的。然后在paddle下还没有这样的语法,请问paddle有没有增加这个功能的准备,多久可以支持使用array来索引tensor。
SKQ6 A$M0P)T2F}40SMV X5

@paddle-bot-old
Copy link

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网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!

@zhiqiu
Copy link
Contributor

zhiqiu commented Jun 16, 2021

hi, paddle最近也在支持比较丰富的slice index类型,以array作为index的,可以参考这个PR: #33000

@geoyee
Copy link
Author

geoyee commented Jun 16, 2021

hi, paddle最近也在支持比较丰富的slice index类型,以array作为index的,可以参考这个PR: #33000

收到,谢谢,查看一下^_^

@geoyee
Copy link
Author

geoyee commented Jun 16, 2021

看到这个pr已经合并了,在as上使用! python -m pip install paddlepaddle-gpu==0.0.0.post101 -f https://paddlepaddle.org.cn/whl/cu101/mkl/develop.html装了最新的develop版本,但是使用还是有点问题。请问这个是我使用的问题还是不能支持这样使用。

IndexError: When index contains a Tensor, its length must be 1, but received 3

具体的代码中如下

F0[:, y0, x0]

其中

F0.shape: [64, 640, 480]
x0.shape: [14181] x0: Tensor(shape=[14181], dtype=int16, place=CUDAPlace(0), stop_gradient=True,
       [2  , 2  , 2  , ..., 476, 476, 477])
y0.shape: [14181] y0: Tensor(shape=[14181], dtype=int16, place=CUDAPlace(0), stop_gradient=True,
       [428, 142, 68 , ..., 227, 110, 398])

@zhiqiu
Copy link
Contributor

zhiqiu commented Jun 17, 2021

看到这个pr已经合并了,在as上使用! python -m pip install paddlepaddle-gpu==0.0.0.post101 -f https://paddlepaddle.org.cn/whl/cu101/mkl/develop.html装了最新的develop版本,但是使用还是有点问题。请问这个是我使用的问题还是不能支持这样使用。

IndexError: When index contains a Tensor, its length must be 1, but received 3

具体的代码中如下

F0[:, y0, x0]

其中

F0.shape: [64, 640, 480]
x0.shape: [14181] x0: Tensor(shape=[14181], dtype=int16, place=CUDAPlace(0), stop_gradient=True,
       [2  , 2  , 2  , ..., 476, 476, 477])
y0.shape: [14181] y0: Tensor(shape=[14181], dtype=int16, place=CUDAPlace(0), stop_gradient=True,
       [428, 142, 68 , ..., 227, 110, 398])

hi,我验证了一下,这个case下确实是还有一些问题。我会和相关负责的同学反馈下,看排期支持下这个用法。

@geoyee
Copy link
Author

geoyee commented Jun 18, 2021

看到这个pr已经合并了,在as上使用! python -m pip install paddlepaddle-gpu==0.0.0.post101 -f https://paddlepaddle.org.cn/whl/cu101/mkl/develop.html装了最新的develop版本,但是使用还是有点问题。请问这个是我使用的问题还是不能支持这样使用。

IndexError: When index contains a Tensor, its length must be 1, but received 3

具体的代码中如下

F0[:, y0, x0]

其中

F0.shape: [64, 640, 480]
x0.shape: [14181] x0: Tensor(shape=[14181], dtype=int16, place=CUDAPlace(0), stop_gradient=True,
       [2  , 2  , 2  , ..., 476, 476, 477])
y0.shape: [14181] y0: Tensor(shape=[14181], dtype=int16, place=CUDAPlace(0), stop_gradient=True,
       [428, 142, 68 , ..., 227, 110, 398])

hi,我验证了一下,这个case下确实是还有一些问题。我会和相关负责的同学反馈下,看排期支持下这个用法。

收到,感谢,待支持后马上体验进行反馈。

@hbwx24
Copy link
Contributor

hbwx24 commented Jun 21, 2021

看到这个pr已经合并了,在as上使用! python -m pip install paddlepaddle-gpu==0.0.0.post101 -f https://paddlepaddle.org.cn/whl/cu101/mkl/develop.html装了最新的develop版本,但是使用还是有点问题。请问这个是我使用的问题还是不能支持这样使用。

IndexError: When index contains a Tensor, its length must be 1, but received 3

具体的代码中如下

F0[:, y0, x0]

其中

F0.shape: [64, 640, 480]
x0.shape: [14181] x0: Tensor(shape=[14181], dtype=int16, place=CUDAPlace(0), stop_gradient=True,
       [2  , 2  , 2  , ..., 476, 476, 477])
y0.shape: [14181] y0: Tensor(shape=[14181], dtype=int16, place=CUDAPlace(0), stop_gradient=True,
       [428, 142, 68 , ..., 227, 110, 398])

hi,我验证了一下,这个case下确实是还有一些问题。我会和相关负责的同学反馈下,看排期支持下这个用法。

根据issues创建了任务卡片

@zhiqiu zhiqiu assigned weixing02 and unassigned zhiqiu Jun 25, 2021
@geoyee
Copy link
Author

geoyee commented Jul 7, 2021

xy = paddle.stack([y1,x1],axis=-1)
F1 = paddle.transpose(F0,[1,2,0])
F2 = paddle.gather_nd(F1,xy)
F3 = paddle.transpose(F2,[1,0])
感觉可以这样写

感谢,空下来后试一试!

@geoyee geoyee closed this as completed Apr 21, 2022
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

No branches or pull requests

5 participants
@zhiqiu @weixing02 @hbwx24 @geoyee and others