# How to find number of features in .pth file

**URL:** <https://discuss.pytorch.org/t/how-to-find-number-of-features-in-pth-file/125350>\
**Category:** vision\
**Created:** [June 29, 2021, 11:23am UTC](https://discuss.pytorch.org/t/how-to-find-number-of-features-in-pth-file/125350 "2021-06-29T11:23:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![i\_m\_a\_q](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/i/a6a055/32.png) [@i\_m\_a\_q](https://discuss.pytorch.org/u/i_m_a_q)\
**Post date:** [June 29, 2021, 11:23am UTC](https://discuss.pytorch.org/t/how-to-find-number-of-features-in-pth-file/125350/1 "2021-06-29T11:23:33Z")

</div>

Hi, I am new to pytorch.  
I have **123.pth** features file.  
I have determined its size and it output “torch.Size([1, 2048, 25, 19])”  
I want to know how many features(region/grid) this file has. Do I need to multiply **25\*19** and answer would be the number of features?

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [June 30, 2021, 5:57am UTC](https://discuss.pytorch.org/t/how-to-find-number-of-features-in-pth-file/125350/2 "2021-06-30T05:57:20Z")

</div>

It depends on the tensor and how you would define “features”.  
Based on the tensor shape it could be an intermediate activation in the shape `[batch_size, channels, height, width]`.  
If you are flattening it and passing to e.g. a linear layers, the usual approach would be to use: `x = x.view(x.size(0), -1)`, which would result in `2048*25*19=972800` “features”.

---

<div class="post-metadata">

**Author:** ![i\_m\_a\_q](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/i/a6a055/32.png) [@i\_m\_a\_q](https://discuss.pytorch.org/u/i_m_a_q)\
**Post date:** [July 6, 2021, 8:23am UTC](https://discuss.pytorch.org/t/how-to-find-number-of-features-in-pth-file/125350/3 "2021-07-06T08:23:47Z")

</div>

@ptrblck thank you for your response. The paper that these features belongs to, says the number of features are from **(100-608)** depending upon the size of image. It means that they are counting **height\*width**? I’d like to minimize the number of features to **36** (i-e using clustering). That’s why I am asking if I could make these features to 36 using h\*w?
