評價此頁

torch.clone#

torch.clone(input, *, memory_format=torch.preserve_format) Tensor#

返回 input 的一個副本。

注意

此函式是可微分的,因此梯度將從此操作的結果流回到 input。要建立與 input 沒有 autograd 關係的張量,請參閱 detach()

此外,當使用 torch.preserve_format 時:如果輸入張量是稠密的(即非重疊的 strided),則會保留其記憶體格式(包括 strides)。否則(例如,非稠密的檢視,如步進切片),輸出將被轉換為稠密(contiguous)格式。

引數

input (Tensor) – 輸入張量。

關鍵字引數

memory_formattorch.memory_format,可選)– 返回張量的期望記憶體格式。預設為 torch.preserve_format