# Modify the dropout and freeze some layers from Encoder-Decoder models

**URL:** <https://discuss.huggingface.co/t/modify-the-dropout-and-freeze-some-layers-from-encoder-decoder-models/17149>\
**Category:** 🤗Transformers\
**Created:** [April 25, 2022, 9:52am UTC](https://discuss.huggingface.co/t/modify-the-dropout-and-freeze-some-layers-from-encoder-decoder-models/17149 "2022-04-25T09:52:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jessicalopez](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/jessicalopez/32/26666_2.png) [@jessicalopez](https://discuss.huggingface.co/u/jessicalopez)\
**Post date:** [April 25, 2022, 9:52am UTC](https://discuss.huggingface.co/t/modify-the-dropout-and-freeze-some-layers-from-encoder-decoder-models/17149/1 "2022-04-25T09:52:06Z")

</div>

Hello,

I am working with BART model and I would like to modify the dropout of some layers in the encoder and in the decoder, how can I do it?

Besides, I would like to freeze the first layer from the encoder, do you have any idea to achieve it?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![bk073](https://avatars.discourse-cdn.com/v4/letter/b/8491ac/32.png) [@bk073](https://discuss.huggingface.co/u/bk073)\
**Post date:** [November 22, 2022, 5:51am UTC](https://discuss.huggingface.co/t/modify-the-dropout-and-freeze-some-layers-from-encoder-decoder-models/17149/2 "2022-11-22T05:51:11Z")

</div>

Are you able to do this?

---

<div class="post-metadata">

**Author:** ![Nitish1295](https://avatars.discourse-cdn.com/v4/letter/n/ad7895/32.png) [@Nitish1295](https://discuss.huggingface.co/u/Nitish1295)\
**Post date:** [November 22, 2022, 8:43am UTC](https://discuss.huggingface.co/t/modify-the-dropout-and-freeze-some-layers-from-encoder-decoder-models/17149/3 "2022-11-22T08:43:20Z")

</div>

Not entirely sure what you want to modify in the dropout layers, but you can use the following to capture all dropouts in your model and then maybe go from there. Not sure if replacements are allowed\

Hope this helps!!

```python
model = AutoModelForSequenceClassification.from_pretrained("bert-base-cased", num_labels=5)

for m in model.modules():
  if m. __class__. __name__.startswith('Dropout'):
    print(f"The droput:{m}, probability:{m.p}")

```
