# Changing requires\_grad means creating new optimizer?

**URL:** <https://discuss.pytorch.org/t/changing-requires-grad-means-creating-new-optimizer/147234>\
**Category:** vision\
**Created:** [March 23, 2022, 9:01am UTC](https://discuss.pytorch.org/t/changing-requires-grad-means-creating-new-optimizer/147234 "2022-03-23T09:01:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hamedB](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/hamedb/32/35498_2.png) [@hamedB](https://discuss.pytorch.org/u/hamedB)\
**Post date:** [March 23, 2022, 9:01am UTC](https://discuss.pytorch.org/t/changing-requires-grad-means-creating-new-optimizer/147234/1 "2022-03-23T09:01:01Z")

</div>

Hi.  
From this [link](https://discuss.pytorch.org/t/how-the-pytorch-freeze-network-in-some-layers-only-the-rest-of-the-training/7088), I read the thread about unfreezing during the training phase. However, in my case I want to freeze some parameter after some epochs.  
First, I have a nn.ParameterDict that includes a set of nn.Parameter parameters with specific key. First of all, whole of nn.ParameterDict parameter is trainable. Then after some epochs, during a for loop, I set the required\_grad to False for some of the nn.Parameter parameters in nn.ParameterDict parameter. However, I see that they are still fine-tuned/trained while their required\_grad is actually False.  
Should I define new optimization when freeze some parameters?  
Thank you
