# How to get a fixed size embedding from the last hidden state of vision models?

**URL:** <https://discuss.huggingface.co/t/how-to-get-a-fixed-size-embedding-from-the-last-hidden-state-of-vision-models/17275>\
**Category:** 🤗Transformers\
**Created:** [April 28, 2022, 8:50am UTC](https://discuss.huggingface.co/t/how-to-get-a-fixed-size-embedding-from-the-last-hidden-state-of-vision-models/17275 "2022-04-28T08:50:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![prithivida](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/prithivida/32/20872_2.png) [@prithivida](https://discuss.huggingface.co/u/prithivida)\
**Post date:** [April 28, 2022, 8:50am UTC](https://discuss.huggingface.co/t/how-to-get-a-fixed-size-embedding-from-the-last-hidden-state-of-vision-models/17275/1 "2022-04-28T08:50:34Z")

</div>

I am using Vision models (ViT, BEiT) as the image encoder and BERT as the Text encoder. I am trying to get a fixed size 1D representation of the last\_hidden\_state of BEiT (Something like what CLIP obtains) to concatenate with a BERT embedding to feed into an MLP head.

I could use the pooler\_output of the image but it doesn’t seem to preserve certain spatial nuances hence I would like to use the last\_hidden\_state

@nielsr Please advice
