快捷鍵

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 具有相同尺寸的 tensor,並以 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 的尺寸將決定輸出 tensor 的尺寸。

  • fill_value – 用於填充輸出 tensor 的數字。

關鍵字參數
  • dtype (torch.dtype, optional) – 返回的 Tensor 的期望資料類型。預設值:如果 None,則預設為 input 的 dtype。

  • layout (torch.layout, optional) – 返回的 tensor 的期望佈局。預設值:如果 None,則預設為 input 的佈局。

  • device (torch.device, optional) – 返回的 tensor 的期望裝置。預設值:如果 None,則預設為 input 的裝置。

  • requires_grad (bool, optional) – 如果 autograd 應該記錄返回的 tensor 上的操作。預設值: False

  • memory_format (torch.memory_format, optional) – 返回的 Tensor 的期望記憶體格式。預設值: torch.preserve_format

文件

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources