# Intermediate Layer

**URL:** <https://discuss.pytorch.org/t/intermediate-layer/90815>\
**Category:** Uncategorized\
**Created:** [July 28, 2020, 11:26am UTC](https://discuss.pytorch.org/t/intermediate-layer/90815 "2020-07-28T11:26:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![truestory1226](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/t/d26b3c/32.png) [@truestory1226](https://discuss.pytorch.org/u/truestory1226)\
**Post date:** [July 28, 2020, 11:26am UTC](https://discuss.pytorch.org/t/intermediate-layer/90815/1 "2020-07-28T11:26:01Z")

</div>

Hi,

I am using a resnet101 model from

```auto
import torchvision.models as models
models.resnet101

```

I want to make certain modifications to the model in such a way that I remove certain layers from the model towards the end and replace them by some other layers(I have successfully done this).

Next, I wanted to take output of one of the intermediate layer and perform some activation on it.

The final output of the model would be the output from activation(intermediate layer) and the one obtained at the end of the network. However, I am not aware of any suitable way of doing this operation where I could take the output of intermediate layer and then perform some operation on it and then return it back.

I have come across some methods on forum where we can register hook and obtain the outcome, but I want to perform further operations after obtaining the output.

Thanks in advance.

---

<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:** [July 30, 2020, 7:21am UTC](https://discuss.pytorch.org/t/intermediate-layer/90815/2 "2020-07-30T07:21:19Z")

</div>

I think for many modifications a custom ResNet implementation would be more suitable than using hooks and other modifications.  
You can copy the code from [here](https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py) and change the model as you wish.

---

<div class="post-metadata">

**Author:** ![truestory1226](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/t/d26b3c/32.png) [@truestory1226](https://discuss.pytorch.org/u/truestory1226)\
**Post date:** [July 31, 2020, 7:18am UTC](https://discuss.pytorch.org/t/intermediate-layer/90815/3 "2020-07-31T07:18:59Z")

</div>

Hi ptrblck,

Thank you for your answer. I will try doing that.
