torch.Tensor中的clone()⽅法
clone() → Tensor
cloneReturns 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_(src, non_blocking=False) → Tensor
Copies the elements from src into self tensor and returns self.
The src tensor must be with the self tensor. It may be of a different datatype or reside on a different device.
Parameters
src () – the source tensor to copy from
non_blocking () – 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.
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论