paddle2.1目前还不支持多维的tensor indexing吗?比如下面这个例子
import numpy as np
import paddle
t = paddle.to_tensor(np.arange(0, 12).reshape(3, 4))
i = paddle.to_tensor([0, 0, 1, 2])
j = paddle.to_tensor([0, 0, 3, 3])
print('t[i]:')
print(t[i])
print('t[i, j]:')
print(t[i, j])
报错信息如下:
t[i]:
W0723 14:43:26.482378 6014 device_context.cc:404] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 10.2, Runtime API Version: 10.2
W0723 14:43:26.487318 6014 device_context.cc:422] device: 0, cuDNN Version: 7.6.
Tensor(shape=[4, 4], dtype=int64, place=CUDAPlace(0), stop_gradient=True,
[[0 , 1 , 2 , 3 ],
[0 , 1 , 2 , 3 ],
[4 , 5 , 6 , 7 ],
[8 , 9 , 10, 11]])
t[i, j]:
Traceback (most recent call last):
File "debug_index.py", line 11, in <module>
print(t[i, j])
File "/home/bio/tools/paddle2.0/lib/python3.7/site-packages/paddle/fluid/dygraph/varbase_patch_methods.py", line 562, in __getitem__
return _getitem_impl_(self, item)
File "/home/bio/tools/paddle2.0/lib/python3.7/site-packages/paddle/fluid/variable_index.py", line 179, in _getitem_impl_
format(len(item)))
IndexError: When index contains a Tensor, its length must be 1, but received 2
3条答案
按热度按时间ne5o7dgx1#
您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档、常见问题、历史Issue、AI社区来寻求解答。祝您生活愉快~
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 API,FAQ,Github Issue and AI community to get the answer.Have a nice day!
yacmzcpb2#
您好,目前还不支持
3lxsmp7m3#
现在换成paddle2.2可以解决这个问题了