快捷方式

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 (張量) – input 的大小將決定輸出張量的大小。

  • fill_value – 用於填充輸出張量的數值。

關鍵字引數
  • dtype (torch.dtype, 可選) – 返回張量所需的資料型別。預設值:如果為 None,則預設為 input 的 dtype。

  • layout (torch.layout, 可選) – 返回張量所需的 layout。預設值:如果為 None,則預設為 input 的 layout。

  • device (torch.device, 可選) – 返回張量所需的 device。預設值:如果為 None,則預設為 input 的 device。

  • requires_grad (bool, 可選) – 如果 autograd 應對返回的張量記錄操作。預設值:False

  • memory_format (torch.memory_format, 可選) – 返回張量所需的 memory format。預設值:torch.preserve_format

文件

訪問 PyTorch 的全面開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深入教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源