Shortcuts

torch.full_like

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

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

Parameters
  • 输入 (张量) – 输入 的大小将决定输出张量的大小。

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

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

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

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

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

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

优云智算