快捷方式

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 的正态分布中的随机数填充。有关复杂数据类型 (dtypes) 的采样过程,请参阅 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 的 dtype。

  • layout (torch.layout, 可选) – 返回张量的期望布局。默认值:如果为 None,则默认为 input 的布局。

  • device (torch.device, 可选) – 返回张量的期望设备。默认值:如果为 None,则默认为 input 的设备。

  • requires_grad (bool, 可选) – 如果 autograd 应该记录在返回的张量上的操作。默认值:False

  • memory_format (torch.memory_format, 可选) – 返回张量的期望内存格式。默认值:torch.preserve_format

文档

访问 PyTorch 的综合开发者文档

查看文档

教程

获取面向初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得您的问题解答

查看资源