# Extract activations from inermediate RESNET layers

**URL:** <https://discuss.pytorch.org/t/extract-activations-from-inermediate-resnet-layers/28892>\
**Category:** Uncategorized\
**Created:** [November 6, 2018, 9:44am UTC](https://discuss.pytorch.org/t/extract-activations-from-inermediate-resnet-layers/28892 "2018-11-06T09:44:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bonzogondo](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/b/74df32/32.png) [@bonzogondo](https://discuss.pytorch.org/u/bonzogondo)\
**Post date:** [November 6, 2018, 9:44am UTC](https://discuss.pytorch.org/t/extract-activations-from-inermediate-resnet-layers/28892/1 "2018-11-06T09:44:24Z")

</div>

Hi,  
I am new to PyTorch and I am currently working on an image classification project, in which I need to use ResNeXt-50 provided by [FB](https://github.com/facebook/fb.resnet.torch).  
Firstly I had some problems loading the GPU-trained model on my CPU-only machine, but I used the built-in PyTorch ResNet-50 implementation and it works fine.

However, I need to extract channel activations from 8,18,31 and 43 layer for further processing.  
I have read many topics on StackOverflow and here, read the documentation, but I did not find any similar problem how to extract intermediate values from a pre-trained model.  
Of course there are some, but usually they pertain ‘simpler’ nets. For example: [1](https://discuss.pytorch.org/t/how-to-extract-features-of-an-image-from-a-trained-model/119/4), [2](https://discuss.pytorch.org/t/access-weights-of-a-specific-module-in-nn-sequential/3627).

I tried using sugesstions from many posts, but all to no avail.  
Could you give me some tips how to approach it?  
Thanks in advance.

I am using PyTorch 0.4.1.post2

---

<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:** [November 6, 2018, 11:28am UTC](https://discuss.pytorch.org/t/extract-activations-from-inermediate-resnet-layers/28892/2 "2018-11-06T11:28:15Z")

</div>

You could use forward hooks to get the desired activation.  
[Here](https://discuss.pytorch.org/t/extract-features-from-layer-of-submodule-of-a-model/20181/2?u=ptrblck) is a small example for a dummy network.
