# How to get the intermediate layers output 'model.feature\_list(input)' for any customized CNN like we do it in a pretrained ResNet34?

**URL:** <https://discuss.pytorch.org/t/how-to-get-the-intermediate-layers-output-model-feature-list-input-for-any-customized-cnn-like-we-do-it-in-a-pretrained-resnet34/113400>\
**Category:** vision\
**Created:** [March 1, 2021, 8:02pm UTC](https://discuss.pytorch.org/t/how-to-get-the-intermediate-layers-output-model-feature-list-input-for-any-customized-cnn-like-we-do-it-in-a-pretrained-resnet34/113400 "2021-03-01T20:02:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kalyan](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/k/58956e/32.png) [@Kalyan](https://discuss.pytorch.org/u/Kalyan)\
**Post date:** [March 1, 2021, 8:02pm UTC](https://discuss.pytorch.org/t/how-to-get-the-intermediate-layers-output-model-feature-list-input-for-any-customized-cnn-like-we-do-it-in-a-pretrained-resnet34/113400/1 "2021-03-01T20:02:36Z")

</div>

I am using Resnet34 pre-trained model and trying to get the intermediate layer outputs by doing model.feature\_list(input) (input.shape = [2,3,32,32]) the outputs are of shape [2, 64, 32, 32], [2, 64, 32, 32], [2, 128 16 16], [2,256,8, 8], and [2, 512, 4, 4].

How can I write a new customized CNN code which would respond to a “model.feature\_list(input)” command and provides the intermediate layer outputs.

---

<div class="post-metadata">

**Author:** ![Dwight\_Foster](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/dwight_foster/32/18182_2.png) [@Dwight\_Foster](https://discuss.pytorch.org/u/Dwight_Foster)\
**Post date:** [March 1, 2021, 10:16pm UTC](https://discuss.pytorch.org/t/how-to-get-the-intermediate-layers-output-model-feature-list-input-for-any-customized-cnn-like-we-do-it-in-a-pretrained-resnet34/113400/2 "2021-03-01T22:16:47Z")

</div>

You could pass through each individual block. Something like this

```auto
x1 = model.layer1(input)
x2 = model.layer2(x1)
x3 = model.layer3(x2)
x4 = model.layer4(x3)

```

etc. Then return the intermediate values.
