首页 Paddle框架 帖子详情
paddle.rand 输出全是0
收藏
快速回复
Paddle框架 问答深度学习 702 3
paddle.rand 输出全是0
收藏
快速回复
Paddle框架 问答深度学习 702 3

我在对paddle API 进行学习时候出现 paddle.rand 输出全是0 情况请问是什么原因导致的?

import paddle

# example 1: attr shape is a list which doesn't contain Tensor.
out1 = paddle.rand(shape=[2, 3]).numpy()*100
out4 = paddle.randn(shape=[2, 3])
# example 2: attr shape is a list which contains Tensor.
dim1 = paddle.to_tensor([2], 'int64')
dim2 = paddle.to_tensor([3], 'int32')
out2 = paddle.rand(shape=[dim1, dim2, 2])shape_tensor = paddle.to_tensor([2, 3])
out3 = paddle.rand(shape_tensor)

输出out1,out2,out3,out4 所有的数据都为0

环境为

Please NOTE: device: 0, GPU Compute Capability: 5.0, Driver API Version: 12.0, Runtime API Version: 11.2
W0505 21:01:24.236230 17196 gpu_resources.cc:91] device: 0, cuDNN Version: 8.2.

0
收藏
回复
全部评论(3)
时间顺序
pad_boy
#2 回复于2023-05

不是0

import paddle
out4 = paddle.randn(shape=[2, 3])
print(out4)

Tensor(shape=[2, 3], dtype=float32, place=Place(gpu:0), stop_gradient=True,
[[-0.83749163, -0.90731597, 0.41067493],
[ 0.93938386, 1.60379386, -0.00137649]])

0
回复
H
Hellinger
#3 回复于2023-05

顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶

0
回复
A
AIStudio482165
#4 回复于2024-01

出现一样情况 cuda11.2 paddle 2.3.2以后版本,随机数gpu下全0 。gaussian_random都是0 设备选cpu就正常可以随机也不知道什么问题。gpu下Tensor.cpu()也Pirnt全0

0
回复
需求/bug反馈?一键提issue告诉我们
发现bug?如果您知道修复办法,欢迎提pr直接参与建设飞桨~
在@后输入用户全名并按空格结束,可艾特全站任一用户