torch.Tensor中的clone()方法


clone() → Tensor

Returns a copy of the self tensor. The copy has the same size and data type as self.

NOTE

Unlike copy_(), this function is recorded in the computation graph. Gradients propagating to the cloned tensor will propagate to the original tensor.

 

返回一個張量的副本,其與原張量的尺寸和數據類型相同。

與copy_()不同,這個函數記錄在計算圖中。傳遞到克隆張量的梯度將傳播到原始張量。

 

copy_(srcnon_blocking=False) → Tensor

Copies the elements from src into self tensor and returns self.

The src tensor must be broadcastable with the self tensor. It may be of a different datatype or reside on a different device.

Parameters
  • src (Tensor) – the source tensor to copy from

  • non_blocking (bool) – if True and this copy is between CPU and GPU, the copy may occur asynchronously with respect to the host. For other cases, this argument has no effect.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM