# Clone and detach in v0.4.0

**URL:** <https://discuss.pytorch.org/t/clone-and-detach-in-v0-4-0/16861>\
**Category:** Uncategorized\
**Created:** [April 24, 2018, 2:20am UTC](https://discuss.pytorch.org/t/clone-and-detach-in-v0-4-0/16861 "2018-04-24T02:20:02Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![kush8singh](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/kush8singh/32/5915_2.png) [@kush8singh](https://discuss.pytorch.org/u/kush8singh)\
**Post date:** [August 1, 2018, 3:01am UTC](https://discuss.pytorch.org/t/clone-and-detach-in-v0-4-0/16861/4 "2018-08-01T03:01:01Z")

</div>

hi,  
i have read many forums trying to understand `.detach()` , and although i get a intutution of what it is , i still don’t understand it completely . I dont understand what removing a tensor from computational graph implies , for ex. consider piece of code below

```auto
x = torch.tensor(([1]))
y = x**2
z = 2*y
w= z**3
z = z.detach()

x.grad.zero_()
w.backward()
print x.grad

```

The output came out to be `48` which is the same with or without `z.detach()` . What does `z.detach() do here ? Why wasn’t it removed from the computational graph?

thanks

---

_[View the full topic](https://discuss.pytorch.org/t/clone-and-detach-in-v0-4-0/16861)._
