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。