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.

 

posted on 2019-07-16 15:54  那抹阳光1994  阅读(6368)  评论(0编辑  收藏  举报

导航