# Freezing intermediate layers while training top and bottom layers

**URL:** <https://discuss.pytorch.org/t/freezing-intermediate-layers-while-training-top-and-bottom-layers/39776>\
**Category:** autograd\
**Created:** [March 13, 2019, 6:54pm UTC](https://discuss.pytorch.org/t/freezing-intermediate-layers-while-training-top-and-bottom-layers/39776 "2019-03-13T18:54:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![t.g](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/t.g/32/74955_2.png) [@t.g](https://discuss.pytorch.org/u/t.g)\
**Post date:** [March 13, 2019, 7:00pm UTC](https://discuss.pytorch.org/t/freezing-intermediate-layers-while-training-top-and-bottom-layers/39776/2 "2019-03-13T19:00:20Z")

</div>

maybe, in my case, I should not be setting `requires_grad=False` to the `L2` parameters, instead I must exclude all L2 parameters from optimizer. That way, right amount of gradients will flow back to L1’s params, but optimizer does not update L2 parameters (which is analogous to freezing L2, yet keeping L1 trainable)

Is this a correct approach 🙂 ?

---

_[View the full topic](https://discuss.pytorch.org/t/freezing-intermediate-layers-while-training-top-and-bottom-layers/39776)._
