# Copy.deepcopy() vs clone()

**URL:** <https://discuss.pytorch.org/t/copy-deepcopy-vs-clone/55022>\
**Category:** Uncategorized\
**Created:** [September 3, 2019, 7:33am UTC](https://discuss.pytorch.org/t/copy-deepcopy-vs-clone/55022 "2019-09-03T07:33:29Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![spanev](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/spanev/32/14892_2.png) [@spanev](https://discuss.pytorch.org/u/spanev)\
**Post date:** [September 3, 2019, 9:19am UTC](https://discuss.pytorch.org/t/copy-deepcopy-vs-clone/55022/2 "2019-09-03T09:19:14Z")

</div>

Hi @Shisho_Sama,

For `Tensor`s in most cases, you should go for `clone` since this is a PyTorch operation that will be recorded by autograd.

```auto
>>> t = torch.rand(1, requires_grad=True)
>>> t.clone()
tensor([0.4847], grad_fn=<CloneBackward>) # <=== as you can see here

```

When it comes to `Module`, there is no `clone` method available so you can either use `copy.deepcopy` or create a new instance of the model and just copy the parameters, as proposed in this post [Deep copying PyTorch modules](https://discuss.pytorch.org/t/deep-copying-pytorch-modules/13514/2).

---

_[View the full topic](https://discuss.pytorch.org/t/copy-deepcopy-vs-clone/55022)._
