# Weights disconnection implementation

**URL:** <https://discuss.pytorch.org/t/weights-disconnection-implementation/19314>\
**Category:** autograd\
**Created:** [June 7, 2018, 4:11am UTC](https://discuss.pytorch.org/t/weights-disconnection-implementation/19314 "2018-06-07T04:11:31Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![tengerye](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/t/a6a055/32.png) [@tengerye](https://discuss.pytorch.org/u/tengerye)\
**Post date:** [June 8, 2018, 2:36am UTC](https://discuss.pytorch.org/t/weights-disconnection-implementation/19314/11 "2018-06-08T02:36:13Z")

</div>

Yes, sure, thank you.

Continue my codes on the original post.

```auto
mask_weights.register_hook(print)

z = torch.Tensor([[1], [1]])
# tensor([[1.],
# [1.]])

out = (y-z).mean()
# tensor(-0.6595)

out.backward()
# tensor([[0.1920, 0.1757, 0.0046],
# [0.1920, 0.1757, 0.0046]])

weights.grad
# tensor([[0.0000, 0.1757, 0.0000],
# [0.1920, 0.0000, 0.0046]])

```

As you can see, the value of gradients of `mask_weights` are not masked.

---

_[View the full topic](https://discuss.pytorch.org/t/weights-disconnection-implementation/19314)._
