# Freeze Lower Layers with Auto Classification Model

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffreeze-lower-layers-with-auto-classification-model%2F11386%3E%5C
**Category:** 🤗Transformers\
**Created:** [November 5, 2021, 12:39pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffreeze-lower-layers-with-auto-classification-model%2F11386 "2021-11-05T12:39:03Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [November 5, 2021, 12:58pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffreeze-lower-layers-with-auto-classification-model%2F11386%2F2 "2021-11-05T12:58:19Z")

</div>

Yes, in PyTorch freezing layers is quite easy. It can be done as follows:

```auto
from transformers import AutoModelForSequenceClassification

model = AutoModelForSequenceClassification.from_pretrained(“bert-base-cased”, num_labels=1)

for name, param in model.named_parameters():
     if name.startswith("..."): # choose whatever you like here
        param.requires_grad = False

```

---

_[View the full topic](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffreeze-lower-layers-with-auto-classification-model%2F11386)._
