Paddle paddle 整数除法结果还是整数

eqfvzcg8  于 2022-10-22  发布在  其他
关注(0)|答案(1)|浏览(173)

paddle 整数除法结果还是整数
torch 整数除法结果是浮点数
感觉 paddle 这个逻辑不太合适,希望可以修一下
import paddle
import torch
a = paddle.to_tensor([327])
b = paddle.to_tensor([80])
a / b
Tensor(shape=[1], dtype=int64, place=CUDAPlace(0), stop_gradient=True,
[4])
c = torch.tensor([327])
d = torch.tensor([80])
c / d
tensor([4.0875])
a
Tensor(shape=[1], dtype=int64, place=CUDAPlace(0), stop_gradient=True,
[327])
b
Tensor(shape=[1], dtype=int64, place=CUDAPlace(0), stop_gradient=True,
[80])
c
tensor([327])
c.dtype
torch.int64
d
tensor([80])
d.dtype
torch.int64

但是 b = int(b) 之后再 a / b, 结果又是浮点数了,这个很不合理,paddle.int64 的行为应该与 int 一致

mwkjh3gx

mwkjh3gx1#

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

相关问题