-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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中tensor维度的问题 #39825
Comments
您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网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! |
如上,tensor也不能只将某段数据更改为我们需要的数据,使用set_value是由于我在某个程序运行时, 我希望我可以对有梯度的tensor的其中一部分进行更改。 |
你好,感谢反馈,这个需求我们记录下哈~ |
这个因为 __getitem__从中取值时,将遍历的scalar元素转为 shape为1的Tensor,目前框架还没支持空维Tensor。如需更改,则要修改__getitem__中的返回值,针对遍历的单个元素返回scalar |
0维Tensor在EinOps这个开源项目中也有需求,项目作者也期待咱们框架可以尽早支持0维Tensor~ |
啥时候会支持0维tensor有具体消息吗?感觉这个太重要了... |
我这边对这方面认知有些生疏,可以说说有哪些应用场景吗?如果能有个比较常见的场景或者玩法,我也好去催一下他们(哈哈哈) |
我举一个简单的场景,现在有2个tensor,我希望将它们的首元素合并为一个tensor,按照正常思维,合并得到的元素应该是一个shape为(2,)的1阶tensor对吧 x=paddle.rand([2])
y=paddle.rand([2])
paddle.stack([x[0],y[0]]) 但是得到的结果却是一个shape为(2,1)的2阶tensor
那么为了得到预期结果,我不得不对输出再进行一次reshape。 BATCH=8
x=paddle.rand([BATCH,1])
y=paddle.rand([BATCH,1])
paddle.stack([x[0],y[0]]) 得到的结果是也一个shape为(2,1)的2阶tensor,那么这个时候就会和上面引起严重歧义,不得不增加很多代码来判断此时到底应不应该reshape |
@Shelly111111 @GT-ZhangAcer @phoenixsfly 你好,飞桨将于2.5版本全面支持0维Tensor,上述反馈的0D问题也将同时解决。(索引API需要设置 欢迎试用并安装develop 版本的paddle whl包,将体验最新的0维特性:https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/develop/install/pip/linux-pip.html Hello, Paddle will fully support the 0-dimensional Tensor in version 2.5, and the 0D issue will also be resolved at the same time. |
’‘’代码’‘’
import paddle
a = paddle.arange(5)
print(a)
ls = []
for i in a:
ls.append(i)
print(paddle.to_tensor(ls))
’‘’输出‘’‘
Tensor(shape=[5], dtype=int64, place=CUDAPlace(0), stop_gradient=True,
[0, 1, 2, 3, 4])
Tensor(shape=[5, 1], dtype=int64, place=CUDAPlace(0), stop_gradient=True,
[[0],
[1],
[2],
[3],
[4]])
如上,生成了一个尺寸为[5]的tensor,然后将其依次取出并加入一个列表中,再将列表转为tensor后,尺寸便会增加一个维度。对照pytorch以及numpy时并不会如此,如果可以,建议更新一下tensor的数组操作。
The text was updated successfully, but these errors were encountered: