评价此页

torch.full_like#

torch.full_like(input, fill_value, \*, dtype=None, layout=torch.strided, device=None, requires_grad=False, memory_format=torch.preserve_format) Tensor#

返回一个与 input 大小相同且用 fill_value 填充的张量。torch.full_like(input, fill_value) 等同于 torch.full(input.size(), fill_value, dtype=input.dtype, layout=input.layout, device=input.device)

参数
  • input (Tensor) – input 的大小将决定输出张量的大小。

  • fill_value – 用于填充输出张量的数值。

关键字参数
  • dtype (torch.dtype, 可选) – 返回张量所需的数据类型。默认值: 如果为 None,则默认为 input 的 dtype。

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

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

  • requires_grad (bool, 可选) – 是否应在返回的张量上记录自动梯度操作。默认值: False

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