# BertForSequenceClassification: Can I get the last hidden state?

**URL:** <https://discuss.huggingface.co/t/bertforsequenceclassification-can-i-get-the-last-hidden-state/29263>\
**Category:** Beginners\
**Created:** [January 9, 2023, 10:35pm UTC](https://discuss.huggingface.co/t/bertforsequenceclassification-can-i-get-the-last-hidden-state/29263 "2023-01-09T22:35:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![petasis](https://avatars.discourse-cdn.com/v4/letter/p/e47c2d/32.png) [@petasis](https://discuss.huggingface.co/u/petasis)\
**Post date:** [January 9, 2023, 10:35pm UTC](https://discuss.huggingface.co/t/bertforsequenceclassification-can-i-get-the-last-hidden-state/29263/1 "2023-01-09T22:35:31Z")

</div>

Hi all,

Is there a way to get the last hidden state (only) from a BertForSequenceClassification instance?

If I enable the output\_hidden\_states=True config option, I get an out of memory error during evaluation.

Regards,

George
