# Extracting and using features from a pretrained model

**URL:** <https://discuss.pytorch.org/t/extracting-and-using-features-from-a-pretrained-model/20723>\
**Category:** Uncategorized\
**Created:** [July 5, 2018, 1:56am UTC](https://discuss.pytorch.org/t/extracting-and-using-features-from-a-pretrained-model/20723 "2018-07-05T01:56:15Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![KrnTneja](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/krntneja/32/5420_2.png) [@KrnTneja](https://discuss.pytorch.org/u/KrnTneja)\
**Post date:** [July 5, 2018, 6:06am UTC](https://discuss.pytorch.org/t/extracting-and-using-features-from-a-pretrained-model/20723/4 "2018-07-05T06:06:36Z")

</div>

Sure you can do whatever you want with this model! To extract the features from, say (2) layer, use `vgg16.features[:3](input)`. Note that `vgg16` has 2 parts `features` and `classifier`. You can call them separately and slice them as you wish and use them as operator on any input.

For the above example, `vgg16.features[:3]` will slice out first 3 layers (0, 1 and 2) from the `features` part of model and then I operated the sliced sequence on `input`.

---

_[View the full topic](https://discuss.pytorch.org/t/extracting-and-using-features-from-a-pretrained-model/20723)._
