torch.randn_like()函数

torch.randn_like(input, *, dtype=None, layout=None, device=None, requires_grad=False, memory_format=torch.preserve_format) -> Tensor

 返回一个和输入大小相同的张量,其由均值为0、方差为1的标准正态分布填充。

torch.randn_like(input)等价于torch.randn(input.size(), dtype=input.dtype, layout=input.layout, device=input.device)

dtype(torch.dtype, optional)期望返回张量的类型,默认为input的类型
layout(torch.layout, optional)期望返回张量的分布,默认为input的分布
device(torch.device, optional)期望返回张量使用的设备,默认与input相同
requires_grad(bool, optional)如果需要在返回张量上保存梯度,默认为False
memory_format(torch.memory_format, optional)期望返回张量的保存类型,默认为torch.preserve_format

posted @ 2022-03-14 11:38  Tomorrow1126  阅读(5572)  评论(0编辑  收藏  举报