# Model.zero\_grad() or optimizer.zero\_grad()?

**URL:** <https://discuss.pytorch.org/t/model-zero-grad-or-optimizer-zero-grad/28426>\
**Category:** Uncategorized\
**Created:** [October 31, 2018, 8:50am UTC](https://discuss.pytorch.org/t/model-zero-grad-or-optimizer-zero-grad/28426 "2018-10-31T08:50:56Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ritchieng](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ritchieng/32/7321_2.png) [@ritchieng](https://discuss.pytorch.org/u/ritchieng)\
**Post date:** [October 31, 2018, 9:10am UTC](https://discuss.pytorch.org/t/model-zero-grad-or-optimizer-zero-grad/28426/3 "2018-10-31T09:10:43Z")

</div>

If you’re referring to:

```auto
optimizer = optim.SGD(net.parameters())

```

They’re the same.

---

_[View the full topic](https://discuss.pytorch.org/t/model-zero-grad-or-optimizer-zero-grad/28426)._
