# How to freez a model?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-freez-a-model%2F12819%3E%5C
**Category:** 🤗Transformers\
**Created:** [December 14, 2021, 5:18pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-freez-a-model%2F12819 "2021-12-14T17:18:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmad](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ahmad/32/13322_2.png) [@Ahmad](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAhmad)%5C
**Post date:** [December 14, 2021, 5:18pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-freez-a-model%2F12819%2F1 "2021-12-14T17:18:39Z")

</div>

I use

```auto
        for p in model.parameters():
            p.requires_grad = False

```

to freeze a T5 model (t5-small), but when I print parameters that require grad, there is still one parameter with the size `32121x512`. What is this? Is it the embeddings matrix? Should I freeze it too? It seems backward gradients affect this one remaining parameter.

---

<div class="post-metadata">

**Author:** ![Ahmad](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ahmad/32/13322_2.png) [@Ahmad](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAhmad)%5C
**Post date:** [December 14, 2021, 6:02pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-freez-a-model%2F12819%2F2 "2021-12-14T18:02:52Z")

</div>

It seems I called `model.resize_token_embeddings(len(tokenizer))` after freezing parameters, and it can reset the embeddings require\_grad to True
