torch.randn_like¶
- torch.randn_like(input, *, dtype=None, layout=None, device=None, requires_grad=False, memory_format=torch.preserve_format) Tensor¶
返回一个与
input大小相同的张量,该张量填充了来自均值为 0、方差为 1 的正态分布的随机数。有关复杂数据类型的采样过程,请参阅torch.randn()。torch.randn_like(input)等效于torch.randn(input.size(), dtype=input.dtype, layout=input.layout, device=input.device)。- 参数
input (Tensor) –
input的大小将决定输出张量的大小。- 关键字参数
dtype (
torch.dtype,可选) – 返回张量的所需数据类型。默认值:如果为None,则默认为input的数据类型。layout (
torch.layout,可选) – 返回张量的所需布局。默认值:如果为None,则默认为input的布局。device (
torch.device,可选) – 返回张量的所需设备。默认值:如果为None,则默认为input的设备。requires_grad (bool, 可选) – 是否应记录返回张量上的操作。默认值:
False。memory_format (
torch.memory_format,可选) – 返回张量的所需内存格式。默认值:torch.preserve_format。