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