# Output intermediate layer from the torch.jit.ScriptModule version of the network

**URL:** <https://discuss.pytorch.org/t/output-intermediate-layer-from-the-torch-jit-scriptmodule-version-of-the-network/30885>\
**Category:** Uncategorized\
**Created:** [November 29, 2018, 4:53pm UTC](https://discuss.pytorch.org/t/output-intermediate-layer-from-the-torch-jit-scriptmodule-version-of-the-network/30885 "2018-11-29T16:53:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrjusha](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/andrjusha/32/4122_2.png) [@Andrjusha](https://discuss.pytorch.org/u/Andrjusha)\
**Post date:** [November 29, 2018, 4:53pm UTC](https://discuss.pytorch.org/t/output-intermediate-layer-from-the-torch-jit-scriptmodule-version-of-the-network/30885/1 "2018-11-29T16:53:34Z")

</div>

Hi guys,

I have the following problem. I use Torch Script for saving the trained model. Afterwards I need to load it and  
take the gradient of the model output with respect to one of the intermediate layers output. At the same time I don’t want to output this intermediate layer with the forward method. As far as I understand register\_forward\_hook method is not yet implemented in ScriptModule. Could you please tell, if there is another way to solve this problem?

Best,  
Andrei

---

<div class="post-metadata">

**Author:** ![jinfagang](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/jinfagang/32/9405_2.png) [@jinfagang](https://discuss.pytorch.org/u/jinfagang)\
**Post date:** [June 3, 2022, 3:13pm UTC](https://discuss.pytorch.org/t/output-intermediate-layer-from-the-torch-jit-scriptmodule-version-of-the-network/30885/2 "2022-06-03T15:13:07Z")

</div>

Do u find a solution?
