# Easy VGG feature extraction module

**URL:** <https://discuss.pytorch.org/t/easy-vgg-feature-extraction-module/45780>\
**Category:** vision\
**Created:** [May 21, 2019, 8:35am UTC](https://discuss.pytorch.org/t/easy-vgg-feature-extraction-module/45780 "2019-05-21T08:35:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmcm](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/m/d07c76/32.png) [@mmcm](https://discuss.pytorch.org/u/mmcm)\
**Post date:** [May 21, 2019, 8:35am UTC](https://discuss.pytorch.org/t/easy-vgg-feature-extraction-module/45780/1 "2019-05-21T08:35:00Z")

</div>

If you ever wanted to do this:

```python
r11, r31, r51 = vgg_net.forward(targets=['relu1_1', 'relu3_1', 'relu5_1'])

```

then this module is for you! 🙂

This is something I made to scratch my own itch. I wanted to extract multiple features from (mostly VGG) models in a single forward pass, by addressing the layers in a nice (human readable and human memorable) way, without making a subclass for every combination of features I want to run.

After being unhappy with the solution I found [here](https://discuss.pytorch.org/t/accessing-any-feature-of-pretrained-net-by-name/15568) I sat down and made a module that is pretty much a replacement for `torchvision.models.vgg`. And now I finally published it as a PyPI module, instead of copying the files from one project to the next 😝

You can find it on github:

> **[black-puppydog/pytorch\_vgg\_named](https://github.com/black-puppydog/pytorch_vgg_named)**
>
> Provides VGG networks to do things like this: r11, r31, r51 = net.forward(targets=\['relu1\_1', 'relu3\_1', 'relu5\_1'\]). Nuff said. :) - black-puppydog/pytorch\_vgg\_named

or simply install it via pip:

```auto
pip install pytorch-vgg-named

```

I also added the **normalized VGG** weights provided by Leon Gatys. If you use these, pay attention to the note on normalization in the readme file.

If you need help, or have feedback, reach out to me here or on github, or twitter, or email, or or or… 😛
